⚡ Zig Guide LiveUnofficialbut fully verified
✓ Zig 0.17.0-dev.1503+1f1bee62eOn 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. Take the long way through the first two sections; this path is the spine of them.

  1. InstallationGetting Started
  2. Hello WorldGetting Started
  3. Running TestsGetting Started
  4. AssignmentLanguage
  5. ArraysLanguage
  6. If ExpressionsLanguage
  7. While LoopsLanguage
  8. For LoopsLanguage
  9. FunctionsLanguage
  10. DeferLanguage
  11. ErrorsLanguage
  12. PointersLanguage
  13. SlicesLanguage
  14. OptionalsLanguage
  15. StructsLanguage
  16. AllocatorsStandard Library
  17. ArrayListStandard Library

Then Data Structures, which makes you answer who frees what.

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. ComptimeLanguage
  14. The Io InterfaceStandard Library

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

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

Then UDP and HTTP, 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.