Zig
A C alternative with explicit control flow, no hidden allocations, and built-in C interoperability.
27 steps across 1 tours, from the basics to complete programs.
The tours
- First released
- 2016
- Created by
- Andrew Kelley
- Typing
- Static and strict -- an unused variable is a compile error, not a warning
- Snippets target
- 0.16
- File extensions
- .zig, .zon
What it is for
Zig is a systems language built on refusals: no hidden control flow, no hidden allocations, no preprocessor, no macros. A function that allocates takes an allocator as a parameter, so the caller always knows; errors are values in the return type, so they cannot be ignored silently. The result reads like C with the footguns filed off and the build system built in.
comptime is the language's one big idea: the same Zig runs at compile time, and generics, reflection, and what other languages do with templates or macros all fall out of that single mechanism. The compiler doubles as a first-class C/C++ cross compiler — zig cc targets other operating systems and architectures out of the box, which is why some projects adopt the toolchain before the language.
The flagship proof is Bun, the JavaScript runtime written in Zig, with TigerBeetle's financial database close behind. The language is still pre-1.0 and moves: standard library APIs churn between minor versions (these seeds track 0.16), which the community accepts as the price of getting the design right before freezing it.
Where it came from
Andrew Kelley started Zig in 2015, frustrated that C had no successor that stayed C-sized: Rust and C++ solved safety and abstraction by growing, and Zig bet instead on shrinking — fewer features, each earning its keep. Early versions already had the shape: errors as values, optionals instead of null, comptime instead of a macro language.
The Zig Software Foundation formed in 2020 to fund development through donations rather than a corporate owner, and the self-hosted compiler landed in 0.10 (2022), replacing the C++ bootstrap with Zig compiling itself — dramatically faster and the base for incremental compilation work since.
Bun's 2022 debut put Zig in production JavaScript infrastructure, and TigerBeetle showed it in a database built for correctness under pressure. Releases 0.11 through 0.16 kept reworking the standard library — I/O and containers most visibly — while the language core has stayed close to settled, with 1.0 promised only when it is actually done.
What it is like to type
Zig types in dots and pipes: .{} builds tuples and structs, .field and .tag lean on inference, |captures| catch payloads in if, while, and for, and every builtin starts with @. Semicolons and braces are C's, identifiers run snake_case with camelCase functions and PascalCase types, and try lands at the start of any line that can fail. The rhythm is short punchy tokens with symbol clusters at every unwrap — brisk once your fingers learn the dot-brace shapes.
27 steps across 1 tours, from the basics to complete programs.