Zig Guide Live
A tutorial for the Zig programming language. Each build compiles and runs every snippet against current Zig master. If an example on this site were out of date, the build would fail.
The snippets run in your browser as WebAssembly. Your browser runs the same artifact that CI verified. There is no server, and you install nothing.
Zig changes fast. If people only proofread documentation, it becomes out of date, and nobody sees the problem. Every night, CI verifies this guide again against a new compiler. The site publishes again only when every snippet still passes. For the exact mechanism, read how this guide is verified. That page also tells you what occurs to the snippets that a browser cannot run. If you use a tagged release, read what changed.
Read the guide → or select a reading path.
What is in it
The guide has 272 chapters in seven tracks, in one reading order. The arrows at the bottom of every page follow that order. Thus you can read the guide from the start to the end.
- FoundationsThe language and its standard library. Start here.
- GroundworkWhat the machine does, from zero. The track assumes no C and no earlier systems work.
- SystemsZig and the world outside the process: networks, builds, C, wasm and pixels.
- CookbookRecipes for tasks. Each recipe is a complete program that CI compiled and ran.
- From ScratchRebuild the tools that you use every day, one program at a time, with only code that you wrote.
- ProjectsOne library at a time, designed in public, with one decision in each chapter.
- PracticeThe algorithms that a contest problem expects you to know. Each program prints the steps that it took.
Riddle breaks
Short videos from the author of this guide. Most are riddles: each riddle asks the question first and shows the answer at the end. Some are jokes. The videos play here, on this page.
Which number reads the same upside down?
▶ Play the riddleThree 3s. Make 12. How?
▶ Play the riddleJ F M A M J J. What comes next?
▶ Play the riddleTwo trains, 300 km apart. When do they meet?
▶ Play the riddle
More from Riddle Masti on YouTube →
What your browser needs
To run a snippet, your browser needs WebAssembly and JavaScript, and nothing else. The scripts here are built for Chrome and Edge 111, Firefox 114, and Safari 16.4 (iOS and iPadOS 16.4) or newer. On an older browser, or with JavaScript off, you can still read every chapter. Every snippet is on the page, highlighted and complete. Only the Run button is missing.
- When you press Run, the page downloads one
.wasmfile. The file is about 70 KB for a typical snippet and about 150 KB for the largest. The snippets that show a safety check fail are an exception, at about 1.2 MB each. The page keeps the compiled module, so a second run of the same snippet downloads nothing. - The four chapters that teach vectors are compiled with WebAssembly SIMD. Without SIMD, the compiler would remove the vector code, with no warning. Firefox disables wasm SIMD on x86 processors without SSE4.1, in all versions. Thus those four chapters can fail to load on a machine where every other snippet runs. If that occurs, the playground names the missing requirement, and does not show the raw engine error.
- When you first edit a snippet, the page loads a code editor of about 500 KB. The page does not load the editor when you only read or run.
- You install nothing, and nothing runs on a server. A snippet runs in the sandbox of the page. The sandbox has only an empty directory in memory, and no network and no input. Thus some examples say that CI compiled them, but that they cannot run here.
Who writes it
Rajesh Pillai writes this guide, with AI assistance. It is an unofficial community guide, and is not affiliated with the Zig Software Foundation. The documentation of the foundation is at ziglang.org. Read more about what this guide is and what it is not, and how to report an error in a chapter.