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.
Every code block in chapters/ mirrors the matching examples/*.zig file
and has been compiled against the target Zig version.
Install Zig 0.16.0 — brew install zig on macOS, or grab a tarball from
ziglang.org/download. Then:
$ zig run examples/01-hello-world.zig
Hello, World!
$ zig test examples/31-testing.zig # tests
$ zig run examples/44-c-interop.zig -lc # link libc
Zig by Example is inspired by Go by Example by Mark McGranaghan. Examples target Zig 0.16.