Introduction to Zig

1.1 What is Zig?

A general-purpose systems programming language and toolchain created by Andrew Kelley (first announced in 2016). It's developed by the non-profit Zig Software Foundation.

Goal: be a better C: robust, optimal, and reusable software, with no hidden surprises.

Compiles through LLVM and Zig's own self-hosted backends (the x86_64 backend is the default for Debug builds on supported targets since 0.15). It produces native code for dozens of targets.

1.2 Zig's Core Principles ("Zen of Zig")

No hidden control flow: no operator overloading, no exceptions, no hidden function calls (properties, destructors).

No hidden memory allocations: every allocation goes through an explicit Allocator you pass in.

No preprocessor, no macros: comptime replaces them with ordinary Zig code run at compile time.

Communicate intent precisely. Edge cases matter. Favor reading code over writing it.

Only one obvious way to do things. Runtime crashes are better than bugs. Compile errors are better than runtime crashes.

zig zen prints the full list.

1.3 Key Features

Run arbitrary Zig code at compile time. Types are first-class values. Generics without special syntax.

Choose your memory strategy per call site Errors as values with try/catch, plus error return traces ?T instead of null pointers

Debug/ReleaseSafe check for UB (overflow, bounds, null). ReleaseFast/ReleaseSmall trade safety for speed.

Import C headers directly (@cImport). Zig is also a drop-in C/C++ compiler (zig cc).

Build for any supported target out of the box, with libc included

Builds are written in Zig (build.zig), plus a built-in package manager Small, simple language

No classes, inheritance, RAII, exceptions, or macros

1.4 Who Uses Zig?

Bun (JavaScript runtime), TigerBeetle (financial database), Ghostty (terminal emulator), Uber (uses zig cc for cross-compiling), Mach (game engine), River (Wayland compositor), Roc language tooling, plus embedded and game projects.

1.5 Zig vs Other Systems Languages

Manual + allocators Runtime checks (mode-dependent) Macros + generics Hidden control flow Some (Drop, traits)