Learn Zig
Learn Zig book notes, organized into 20 chapters.
Learn Zig
| Chapter | Title | Description |
|---|---|---|
| 1 | Chapter 1. Hello, Zig | The first program in Zig is small. |
| 2 | Chapter 2. Names and Declarations | A Zig program is made from declarations. |
| 3 | Chapter 3. Blocks are Expressions | A block is a sequence of statements inside braces. |
| 4 | Chapter 4. Defining Functions | A function groups statements into a single operation. Functions are the basic unit of organization in a Zig program. |
| 5 | Chapter 5. Addresses and Pointer Types | A variable has a value. In Zig, a variable may also have an address. |
| 6 | Chapter 6. Fixed-Size Arrays | An array is a sequence of values of the same type. |
| 7 | Chapter 7. Struct Declarations | A struct is a type made from named fields. |
| 8 | Chapter 8. Error Sets | Programs fail for many reasons. A file may not exist. Memory allocation may fail. Input may be malformed. A network connection may close unexpectedly. |
| 9 | Chapter 9. The Optional Type | Sometimes a value may or may not exist. |
| 10 | Chapter 10. What comptime Means |
A Zig program runs in two stages. |
| 11 | Chapter 11. Generic Functions | A function in Zig can take types as parameters. |
| 12 | Chapter 12. Why Allocation Is Explicit | A program uses memory to store values. |
| 13 | Chapter 13. Files | Most programs spend their time moving bytes. |
| 14 | 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. |
| 15 | Chapter 15. zig build |
Large programs are rarely built with a single compiler command. |
| 16 | Chapter 16. Calling C | One of Zig's design goals is direct interoperability with C. |
| 17 | Chapter 17. Target Triples | One of Zig's main design goals is cross compilation. |
| 18 | Chapter 18. Threads | A thread is an independent flow of execution. |
| 19 | Chapter 19. Undefined Behavior | Zig gives the programmer direct access to memory, integers, pointers, and machine operations. This makes many programs simple and efficient. It also makes some operations... |
| 20 | Chapter 20. A Command-Line Parser | Many programs begin the same way: they read command-line arguments, decide what the user requested, then execute an operation. |
| Appendix | Appendix | The first program in Zig is small. |