Zig Fundamentals
Zig is a general-purpose programming language for systems work: operating systems, embedded firmware, databases, compilers, and command-line tools. It is a modern alternative to C, keeping manual control over memory and hardware while adding compile-time code execution, built-in testing, and a toolchain that also compiles C and C++ and cross-compiles out of the box. It exists to make low-level code easier to read, test, and port, with no garbage collector and no heavy runtime.
itProgramming languages | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic - Zig Fundamentals
Zig is a programming language for the low-level work that C has always done: operating systems, device firmware, databases, compilers, small fast tools. The corridor version, rather than the homepage version, is this: Zig is C with the sharp edges filed off and an actual toolchain in the box.
Before Zig, that work meant C, and C is a mixed blessing. It is small and close to the machine and links with everything, which is why it never went away. It also has undefined behavior that quietly corrupts your program, a text preprocessor instead of real compile-time code, error handling that is only a polite convention about return values, and no standard way to build a project or pull in a dependency. Zig keeps the good half and replaces the rest.
Three ideas carry most of the language. First, no hidden allocations: the language never touches the heap on its own, so anything needing memory takes an allocator (a value you pass in that hands out and reclaims memory) as a visible parameter. Second, errors are values. A function that can fail returns an error union, either an error or a result, and the compiler will not let you ignore it; try passes the error up, catch handles it. Third, comptime: ordinary Zig code that runs during compilation. It replaces macros and templates entirely, and because types are just values at compile time, a generic list is a function that takes a type and returns a type.
The surprise, if you come from C or C++, is what Zig deliberately leaves out. There is no borrow checker. Zig does not prove at compile time that you have no use-after-free and no data races. What it gives you instead is build modes: in Debug and ReleaseSafe, checks for overflow, out-of-bounds access, and null unwrapping stop the program cleanly instead of letting it wander into corruption. In ReleaseFast those checks are gone. If you need the compiler itself to guarantee memory safety, that language is Rust, and the course says so plainly.
The other thing worth knowing early: Zig is pre-1.0. The language and standard library still change between releases, sometimes in ways that break your code. This is not a reason to avoid it, but it is a reason to pin the compiler version per project and expect a porting session when you upgrade. Tutorials from a couple of years ago confidently show features, like the old async keyword, that no longer exist.
One feature genuinely stands out. The zig command is a single binary that also contains a full C and C++ compiler and cross-compiler, libc sources included, so building for another platform needs a target string and nothing else. Whole C projects build under zig cc; this is the part even non-Zig teams adopt.
Where to go next: the Cheatsheet has the syntax, allocator, and build-mode tables on one page. Practice covers the zig command line with the reasoning for each command. Field Notes is where production teams tell you what actually hurt. Timeline shows how the language got here, which explains a lot about why it is the way it is.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://ziglang.org/
Supports
- Zig's identity as a general-purpose systems language competing with C
- Current stable version and pre-1.0 release cadence
- Reference-path and Landscape rationale for the project home page
- https://ziglang.org/learn/
Supports
- Existence and scope of the official learning material index
- Zig Learn hub reference-path rationale
- https://ziglang.org/learn/overview/
Supports
- No hidden control flow and no hidden allocations as stated design rules
- Allocator-parameter pattern, comptime and compile-time reflection, zero-cost formatted printing
- Four build modes and their safety-check and optimization trade-offs
- Bundled libc for many targets, cross-compilation by target string, zig cc as a C compiler
- export producing C-ABI symbols; optionals replacing nullable pointers; errors as values that cannot be ignored
- Overview reference-path rationale and multiple quiz answers
- https://ziglang.org/learn/getting-started/
Supports
- Installation, editor setup, and the first zig init project
- Getting Started reference-path rationale
- https://ziglang.org/documentation/master/
Supports
- Primitive types including arbitrary-width integers and float widths
- Pointers (single-item, many-item, sentinel-terminated), arrays, slices
- Optionals and the orelse / .? / if-capture forms
- Error sets, error unions, try, catch, exhaustive error switch, inferred error sets
- defer and errdefer semantics and ordering
- structs, enums, tagged unions, packed and extern variants, @This()
- comptime parameters and blocks, generic type-returning functions, @typeInfo, inline for/while
- Builtins (@import, @sizeOf, @intCast, @as, @memcpy, @compileError, @embedFile and others)
- Integer-overflow operators (+%, +|, @addWithOverflow) and illegal overflow by default
- Zig Test section: test blocks, the zig test runner, std.testing helpers
- Safety checks active in Debug and ReleaseSafe; whole-program compilation of referenced code
- Language reference rationale and every quiz answer citing language semantics
- https://ziglang.org/documentation/master/std/
Supports
- std.mem.Allocator interface and alloc/free/create/destroy
- DebugAllocator (formerly GeneralPurposeAllocator), ArenaAllocator, FixedBufferAllocator, page_allocator, c_allocator, std.testing.allocator
- std.Thread and synchronization primitives; std.mem.span for C strings
- Standard-library reference rationale
- https://ziglang.org/learn/build-system/
Supports
- build.zig as a Zig program exposing a build function that receives a std.Build pointer
- Artifacts and steps forming a dependency graph; the install step as default
- b.addExecutable, b.addLibrary, b.addTest, b.addModule/createModule, b.installArtifact, b.addRunArtifact, b.step, b.dependency
- b.standardTargetOptions and b.standardOptimizeOption feeding -Dtarget and --release
- build.zig.zon dependencies by URL and content hash; no central registry; built from source
- b.addTranslateC build step for C translation
- Build-system reference-path rationale and build/package quiz answers
- https://ziglang.org/learn/why_zig_rust_d_cpp/
Supports
- Point-by-point contrast with C++, D, Rust: no hidden control flow, no hidden allocations, no macros
- Zig has no borrow checker and does not prove memory safety at compile time
- Comparison rationale and the memory-safety-guarantee quiz answer
- Landscape placement for Rust, Go, D as alternatives
- https://ziglang.org/learn/samples/
Supports
- Memory-leak detection with the debug allocator; generic Queue(comptime Child: type) type example
- C interoperability samples and zig cc build commands
- Generic-container quiz answer
- https://ziglang.org/download/
Supports
- Release dates for 0.4.0 through 0.16.0; 0.16.0 stable, master toward 0.17.0; Zig 1.0 not released
- Pre-1.0 status and per-project compiler pinning rationale
- The compiler-upgrade-failure quiz answer
- https://ziglang.org/download/0.6.0/release-notes.html
Supports
- Zig 0.6.0 (2020-04-13) introduced zig cc with bundled libc sources
- Timeline event for zig cc; zig cc quiz answer
- https://ziglang.org/download/0.10.0/release-notes.html
Supports
- Zig 0.10.0 (2022-10-31) made the self-hosted compiler the default
- Timeline event for the self-hosted compiler
- https://ziglang.org/download/0.11.0/release-notes.html
Supports
- Zig 0.11.0 (2023-08-04) added the build.zig.zon package manager
- Timeline event and dependency-declaration quiz answer
- https://ziglang.org/download/0.12.0/release-notes.html
Supports
- Zig 0.12.0 (2024-04-20) removed the async and await keywords pending redesign; build-system rework
- Timeline event; Field Notes tradeoff and shift cards; async pitfall
- https://ziglang.org/download/0.14.0/release-notes.html
Supports
- Zig 0.14.0 (2025-03-05) advanced incremental compilation and the self-hosted x86_64 backend
- Timeline event and the continued pattern of breaking changes
- https://ziglang.org/download/0.15.1/release-notes.html
Supports
- Zig 0.15.1 (2025-08-19) deprecated the generic std.io reader/writer in favor of std.Io.Reader and std.Io.Writer
- Timeline event (Writergate); Field Notes tradeoff and shift cards
- https://ziglang.org/download/0.16.0/release-notes.html
Supports
- Zig 0.16.0 (2026-04-13) consolidated I/O behind a std.Io interface passed as a parameter; @cImport deprecated in favor of the build-system translate-c step
- Intro statements on the evolving std.Io interface and C-translation direction
- https://ziglang.org/news/announcing-zig-software-foundation/
Supports
- The Zig Software Foundation announcement (2020-07-11) as a non-profit funding core contributors
- Timeline event
- https://ziglang.org/news/goodbye-cpp/
Supports
- Retirement of the C++ implementation of the Zig compiler (2022-12-07)
- Timeline context for the self-hosted compiler milestone
- https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html
Supports
- zig cc as a GCC/Clang-compatible drop-in that cross-compiles C, including glibc version targeting
- Timeline event supporting source and the C-interop section of the intro
- https://en.wikipedia.org/wiki/Zig_(programming_language)
Supports
- Andrew Kelley announced Zig on 2016-02-08; first release 0.1.0 on 2017-10-17
- Kelley began working on Zig full time in 2018 funded by donations
- Designer, MIT license, influences, and pre-1.0 status
- Early-history timeline events
- https://tigerbeetle.com/blog/2022-10-12-a-database-without-dynamic-memory/
Supports
- Static allocation at startup bounds behavior under overload and removes runtime allocation-failure paths
- Zig's allocator-as-parameter design makes a no-allocation rule enforceable
- Field Notes difficulty card; the static-allocation quiz answer; intro memory-management paragraph
- https://m.jakstys.lt/2022/how-uber-uses-zig/
Supports
- Uber adopted zig cc for hermetic, cross-compiling C/C++ builds and glibc version targeting
- Paid the Zig Software Foundation for prioritized fixes; issue turnaround ranged from days to more than six months
- Field Notes tradeoff card; the C-interop section of the intro
- https://github.com/zigcc/awesome-zig
Supports
- Curated ecosystem index used to select the Awesome Links entries
- https://zigistry.dev/
Supports
- Browsable Zig package registry; Awesome Links rationale
- https://zigtools.org/zls/
Supports
- ZLS as the Zig language server providing editor completion, navigation, and diagnostics
- Awesome Links rationale
- https://github.com/marler8997/zigup
Supports
- zigup downloads and switches between Zig compiler versions; Awesome Links rationale
- https://github.com/karlseguin/http.zig
Supports
- http.zig as an HTTP/1.1 server library with routing; Awesome Links rationale
- https://github.com/zigzap/zap
Supports
- Zap as a web backend framework built on a C library, exercising Zig C interop; Awesome Links rationale
- https://www.jetzig.dev/
Supports
- Jetzig as a web framework with file-based routing and build-time template rendering on http.zig; Awesome Links rationale
- https://machengine.org/
Supports
- Mach as cross-platform Zig game and graphics modules; Awesome Links rationale
- https://tigerbeetle.com/
Supports
- TigerBeetle as a financial database written in Zig with static memory allocation; Awesome Links and intro production-user claims
- https://ghostty.org/
Supports
- Ghostty as a GPU-accelerated terminal emulator written in Zig for macOS and Linux; Awesome Links and intro production-user claims
- https://bun.sh/
Supports
- Bun as a JavaScript runtime and toolchain with a Zig core; Awesome Links and intro production-user claims
- https://zig.guide/
Supports
- Community feature-by-feature Zig tutorial tracking recent compilers; reference-path rationale
- https://ziglings.org/
Supports
- Ziglings as a set of small broken programs for learning Zig features; reference-path rationale
- https://ziggit.dev/
Supports
- Ziggit as the main Zig discussion forum with help and migration threads; reference-path and Field Notes shift rationale
- https://www.iso.org/standard/82075.html
Supports
- C as the incumbent systems language Zig is designed to replace; Landscape placement
- https://isocpp.org/
Supports
- C++ as the other established systems language Zig contrasts with on size; Landscape placement
- https://www.rust-lang.org/
Supports
- Rust as the alternative when compiler-proven memory safety is the deciding requirement; Landscape placement
- https://go.dev/
Supports
- Go as a garbage-collected alternative sharing Zig's small-language and bundled-toolchain goals; Landscape placement
- https://dlang.org/
Supports
- D as an older better-C/C++ attempt with compile-time function execution; Landscape placement
- https://nim-lang.org/
Supports
- Nim as a C-compiling language with manual or GC memory management and metaprogramming; Landscape placement
- https://odin-lang.org/
Supports
- Odin as a contemporary manual-memory language passing allocators through a context; Landscape placement
- https://github.com/carbon-language/carbon-lang
Supports
- Carbon as an experimental C++ successor for bidirectional interop, not production-ready; Landscape placement
- https://llvm.org/
Supports
- LLVM and Clang as Zig's default backend and the front end zig cc/zig c++ wrap; Landscape placement
- https://cmake.org/
Supports
- CMake as the dominant C/C++ build-and-configure system that build.zig replaces for Zig; Landscape placement
- https://ziglang.org/documentation/master/
Supports
- All infographic labels, tables, and captions restate the course cheatsheet, slides, and intro
