A hands-on introduction to Zig via annotated examples. Zig is a general-purpose, compiled systems language focused on robustness, optimality, and simplicity — no hidden control flow, no hidden allocations, no preprocessor.
- Hello, World
- Values
- Variables
- Integers
- Floats
- Strings
- Arrays
- Slices
- Vectors
- Structs
- Enums
- Unions
- Functions
- Blocks and Statements
- If / Else
- Switch
- While Loops
- For Loops
- Defer
- Errors
- Optionals
- Pointers
- Multi-Pointers
- Slices (Pointers)
- Comptime
- Generics
- Memory Allocation
- ArrayList
- HashMap
- Linked List
- Testing
- Formatting and Print
- File I/O
- Processes
- JSON
- Random Numbers
- Sorting
- Math
- Build System
- C Interop
Zig by Example is inspired by Go by Example by Mark McGranaghan. Examples target Zig 0.14.