⚡ Zig Guide LiveUnofficialbut fully verified
✓ Zig 0.18.0-dev.624+b7f2c6d8fWhat's newOn an older Zig?Blograylib-zig

Reading paths

The guide has one order, and the arrows at the bottom of each page follow that order. The paths below are shortcuts. Each path is a list of chapters for one starting point. Every link goes to the same chapter as the link in the sidebar.

New to systems programming

You wrote software before, but never in a language that made you say where a value is in memory. Start in Groundwork. Groundwork teaches the machine, not the language, and assumes no C. Then read the first two sections completely.

  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. Talk to the Operating SystemSystems from Scratch
  12. InstallationGetting Started
  13. Hello WorldGetting Started
  14. Run 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 read Data Structures, which makes you decide who frees what. Or read the From Scratch track, which makes you build the tools that you use.

From C

You already know pointers, the stack and undefined behaviour. Do not read the tour. Read the parts where Zig is different from C, then go directly to the C interop chapters.

  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. Import CWorking with C
  16. Cross-compilationBuild System

Then read the Cookbook. It shows, in Zig, the programs that you wrote in C before.

From a garbage-collected language

Go, Java, C#, Python, JavaScript. The syntax is not the difficult part. Memory and error handling are difficult, so this path puts both first.

  1. Hello WorldGetting Started
  2. Run TestsGetting Started
  3. OptionalsLanguage
  4. ErrorsLanguage
  5. DeferLanguage
  6. PointersLanguage
  7. SlicesLanguage
  8. AllocatorsStandard Library
  9. Recipe: Catch 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 read Concurrency. Your old runtime also did concurrency for you.

Build it from scratch

You learn a thing when you write it. This path is the main line of the From Scratch track: the primitives that a shell needs, the tools that you use every day, a language, and a web server. Each one is a complete program. If one stage interests you, the track has more chapters on it.

  1. String PrimitivesSurvive the Terminal
  2. Tokenize 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. Parse an HTTP RequestWeb Server
  12. An HTTP ServerWeb Server

Then read the chapters that this path does not include: grep and printf, the bytecode compiler and its VM, and the rest of the web server.

Ship something this week

You will read about the language later. This path 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: Load a JSON ConfigHow-To
  9. Recipe: Word FrequenciesHow-To
  10. Zig BuildBuild System
  11. Build ModesBuild System
  12. Cross-compilationBuild System

Then select the recipe that matches what you build.

Write a network service

A server, a client, or any program that uses a protocol. The framing chapters decide if your program continues to work on a real network. Thus they come before the chapters where 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. Serve Many ClientsNetworking
  10. Failure Is OrdinaryNetworking
  11. Recipe: A Redis RESP Round TripHow-To
  12. Parse an HTTP RequestWeb Server
  13. An HTTP ServerWeb Server
  14. Routes and Query StringsWeb Server
  15. Serve Files SafelyWeb Server

Then read about form bodies, sessions and templates, or the PostgreSQL wire protocol for a larger service.

Upgrade from an older Zig

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

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

Then run your own test suite again against a master build.

If no path fits, use the section list. It shows the full guide, and the first chapter of Getting Started is the start of the full reading order.