Skip to content

Learn Zig

Learn Zig book notes, organized into 20 chapters.

ChapterTitleDescription
1Chapter 1. Hello, ZigThe first program in Zig is small.
2Chapter 2. Names and DeclarationsA Zig program is made from declarations.
3Chapter 3. Blocks are ExpressionsA block is a sequence of statements inside braces.
4Chapter 4. Defining FunctionsA function groups statements into a single operation. Functions are the basic unit of organization in a Zig program.
5Chapter 5. Addresses and Pointer TypesA variable has a value. In Zig, a variable may also have an address.
6Chapter 6. Fixed-Size ArraysAn array is a sequence of values of the same type.
7Chapter 7. Struct DeclarationsA struct is a type made from named fields.
8Chapter 8. Error SetsPrograms fail for many reasons. A file may not exist. Memory allocation may fail. Input may be malformed. A network connection may close unexpectedly.
9Chapter 9. The Optional TypeSometimes a value may or may not exist.
10Chapter 10. What comptime MeansA Zig program runs in two stages.
11Chapter 11. Generic FunctionsA function in Zig can take types as parameters.
12Chapter 12. Why Allocation Is ExplicitA program uses memory to store values.
13Chapter 13. FilesMost programs spend their time moving bytes.
14Chapter 14. std.debugThe std.debug module contains utilities for debugging programs. The most commonly used function is print, which writes formatted output to standard error.
15Chapter 15. zig buildLarge programs are rarely built with a single compiler command.
16Chapter 16. Calling COne of Zig’s design goals is direct interoperability with C.
17Chapter 17. Target TriplesOne of Zig’s main design goals is cross compilation.
18Chapter 18. ThreadsA thread is an independent flow of execution.
19Chapter 19. Undefined BehaviorZig gives the programmer direct access to memory, integers, pointers, and machine operations. This makes many programs simple and efficient. It also makes some operations…
20Chapter 20. A Command-Line ParserMany programs begin the same way: they read command-line arguments, decide what the user requested, then execute an operation.
AppendixAppendixThe first program in Zig is small.
Chapter 1. Hello, ZigThe first program in Zig is small.
8 pages · 16 min
Chapter 2. Names and DeclarationsA Zig program is made from declarations.
9 pages · 30 min
Chapter 3. Blocks are ExpressionsA block is a sequence of statements inside braces.
8 pages · 30 min
Chapter 4. Defining FunctionsA function groups statements into a single operation. Functions are the basic unit of organization in a Zig program.
7 pages · 20 min
Chapter 5. Addresses and Pointer TypesA variable has a value. In Zig, a variable may also have an address.
8 pages · 30 min
Chapter 6. Fixed-Size ArraysAn array is a sequence of values of the same type.
7 pages · 20 min
Chapter 7. Struct DeclarationsA struct is a type made from named fields.
8 pages · 32 min
Chapter 8. Error SetsPrograms fail for many reasons. A file may not exist. Memory allocation may fail. Input may be malformed. A network connection may close unexpectedly.
8 pages · 25 min
Chapter 9. The Optional TypeSometimes a value may or may not exist.
6 pages · 15 min
Chapter 10. What `comptime` MeansA Zig program runs in two stages.
7 pages · 23 min
Chapter 11. Generic FunctionsA function in Zig can take types as parameters.
6 pages · 18 min
Chapter 12. Why Allocation Is ExplicitA program uses memory to store values.
8 pages · 27 min
Chapter 13. FilesMost programs spend their time moving bytes.
8 pages · 21 min
Chapter 14. `std.debug`The std.debug module contains utilities for debugging programs. The most commonly used function is print, which writes formatted output to standard error.
9 pages · 28 min
Chapter 15. `zig build`Large programs are rarely built with a single compiler command.
9 pages · 26 min
Chapter 16. Calling COne of Zig's design goals is direct interoperability with C.
7 pages · 17 min
Chapter 17. Target TriplesOne of Zig's main design goals is cross compilation.
7 pages · 19 min
Chapter 18. ThreadsA thread is an independent flow of execution.
9 pages · 32 min
Chapter 19. Undefined BehaviorZig gives the programmer direct access to memory, integers, pointers, and machine operations. This makes many programs simple and efficient. It also makes some operations...
8 pages · 31 min
Chapter 20. A Command-Line ParserMany programs begin the same way: they read command-line arguments, decide what the user requested, then execute an operation.
10 pages · 34 min
AppendixThe first program in Zig is small.
12 pages · 43 min