⚡ Zig Guide LiveUnofficialbut fully verified
✓ Zig 0.17.0-dev.2122+3e15e99e6What's newOn an older Zig?

Reading paths

The guide has one order and the arrows at the foot of each page follow it. These are the shortcuts. Each one is a run of chapters that answers a particular starting point, and every link goes to the same chapter the sidebar does.

New to systems programming

You have written software, but never in a language that made you say where a value lives. Start in Groundwork, which teaches the machine rather than the language and assumes no C, then take the long way through the first two sections.

  1. Everything Is BytesSystems from Scratch
  2. Numbers Have a SizeSystems from Scratch
  3. Memory Is NumberedSystems from Scratch
  4. The StackSystems from Scratch
  5. Who Owns This MemorySystems from Scratch
  6. Off the EndSystems from Scratch
  7. When the Checks Are OffSystems from Scratch
  8. Strings Are BytesSystems from Scratch
  9. Structs Are LayoutSystems from Scratch
  10. Errors Are ValuesSystems from Scratch
  11. Talking to the Operating SystemSystems from Scratch
  12. InstallationGetting Started
  13. Hello WorldGetting Started
  14. Running TestsGetting Started
  15. AssignmentLanguage
  16. ArraysLanguage
  17. If ExpressionsLanguage
  18. While LoopsLanguage
  19. For LoopsLanguage
  20. FunctionsLanguage
  21. DeferLanguage
  22. ErrorsLanguage
  23. PointersLanguage
  24. SlicesLanguage
  25. OptionalsLanguage
  26. StructsLanguage
  27. AllocatorsStandard Library
  28. ArrayListStandard Library

Then Data Structures, which makes you answer who frees what, or the From Scratch track, which makes you build the tools you have been using.

Coming from C

You already know pointers, the stack and undefined behaviour. Skip the tour and read the places Zig disagrees with C, then go straight at the interop.

  1. Hello WorldGetting Started
  2. Integer RulesLanguage
  3. Runtime SafetyLanguage
  4. PointersLanguage
  5. Many-item PointersLanguage
  6. SlicesLanguage
  7. Sentinel TerminationLanguage
  8. ErrorsLanguage
  9. DeferLanguage
  10. ComptimeLanguage
  11. AllocatorsStandard Library
  12. C Primitive TypesWorking with C
  13. C PointersWorking with C
  14. ABIWorking with C
  15. Importing CWorking with C
  16. Cross-compilationBuild System

Then the Cookbook, which is where the C you would have written shows up.

Coming from a garbage-collected language

Go, Java, C#, Python, JavaScript. The syntax will not be the hard part. Memory and error handling will, so this path front-loads both.

  1. Hello WorldGetting Started
  2. Running TestsGetting Started
  3. OptionalsLanguage
  4. ErrorsLanguage
  5. DeferLanguage
  6. PointersLanguage
  7. SlicesLanguage
  8. AllocatorsStandard Library
  9. Recipe: Catching Memory LeaksHow-To
  10. ArrayListStandard Library
  11. Hash MapsStandard Library
  12. StringsStandard Library
  13. String RecipesStandard Library
  14. ComptimeLanguage
  15. The Io InterfaceStandard Library

Then Concurrency, which is the other thing your old runtime was doing for you.

Build it from scratch

You learn a thing by writing it. This is the spine of the From Scratch track: the primitives a shell needs, the tools you use every day, a language, and a web server. Each one is a complete program, and the track has more of each if a stage grabs you.

  1. String PrimitivesSurvive the Terminal
  2. Tokenizing a Command LineSurvive the Terminal
  3. The Read-Eval-Print LoopSurvive the Terminal
  4. catUnix Tools
  5. wcUnix Tools
  6. sortUnix Tools
  7. makeUnix Tools
  8. A LexerTiny Language
  9. A ParserTiny Language
  10. A Tree-Walking InterpreterTiny Language
  11. Parsing an HTTP RequestWeb Server
  12. An HTTP ServerWeb Server

Then the chapters each section skips here: grep and printf, the bytecode compiler and its VM, and the rest of the web server.

I want to ship something this week

You will read the language later. This is the shortest route to a program that reads input, does work, and writes a result.

  1. InstallationGetting Started
  2. Hello WorldGetting Started
  3. AllocatorsStandard Library
  4. ArrayListStandard Library
  5. Command-Line ArgumentsStandard Library
  6. FilesystemStandard Library
  7. JSONStandard Library
  8. Recipe: Loading a JSON ConfigHow-To
  9. Recipe: Word FrequenciesHow-To
  10. Zig BuildBuild System
  11. Build ModesBuild System
  12. Cross-compilationBuild System

Then pick the recipe that matches what you are building.

Writing a network service

A server, a client, or anything that speaks a protocol. The framing chapters are the ones that decide whether it survives contact with a real network, so they come before the sockets do most of the work.

  1. Readers and WritersStandard Library
  2. The Io InterfaceStandard Library
  3. What a Socket IsNetworking
  4. A TCP Round TripNetworking
  5. Bytes Have No EdgesNetworking
  6. Three Ways to FrameNetworking
  7. A Text Protocol, Both DirectionsNetworking
  8. Binary Protocols and Byte OrderNetworking
  9. Serving Many ClientsNetworking
  10. Failure Is OrdinaryNetworking
  11. Recipe: A Redis RESP Round TripHow-To
  12. Parsing an HTTP RequestWeb Server
  13. An HTTP ServerWeb Server
  14. Routing and Query StringsWeb Server
  15. Serving Files SafelyWeb Server

Then form bodies, sessions and templates, or the PostgreSQL wire protocol for a bigger one.

Upgrading from an older Zig

Your code compiled on 0.13 or 0.14 and does not now. Read what moved, then the four areas that moved the most.

  1. Coming from an Older ZigGetting Started
  2. The Io InterfaceStandard Library
  3. Readers and WritersStandard Library
  4. FormattingStandard Library
  5. ArrayListStandard Library
  6. ArraysLanguage

Then re-run your own test suite against a master build.

None of these fit? The section list is the whole guide, and the first chapter of Getting Started leads through all of it.