Zig Tutorial

Zig is a blazing fast, statically typed, compiled systems programming language with a modern C-like syntax, offering low-level control, built-in memory safety, and powerful meta-programming capabilities. It prioritizes developer happiness with clear error messages, a friendly compiler, and an active community.

Scope: Study the topics in order, compile each example with the Zig toolchain, and use the official manual for authoritative depth.

Zig Study Progress

0% Complete
# ZIG Topic Description
PHASE 1: FOUNDATIONS
01Why Zig & Thinking in ZigOrigins, purpose, paradigms: no hidden control flow or allocation, no macros.
02Toolchain & EnvironmentInstall Zig, run your first program, and understand the four build modes.
03Statements & ExpressionsPunctuation, operators, identifiers, comments, and compiler builtins.
PHASE 2: TYPES & CONTROL
04Data Types & LiteralsExplicit-width integers, floats, bools, arrays, and compile-time literals.
05Control Flowif, switch, while, and for — every construct is an expression.
06Functions & CleanupParameters, return values, defer, errdefer, and inline functions.
PHASE 3: THE CORE OF ZIG
07Compile-Time Metaprogrammingcomptime parameters and variables: generics and reflection in the language itself.
08Pointers & SlicesSingle-item pointers, many-item pointers, slices, alignment, and casting.
09Optionals & Null SafetyNullable values are explicit in the type: ?T, null, orelse, and unwrapping.
10Errors & Error UnionsError sets, error unions, try, catch, and errdefer — errors are values.
PHASE 4: MEMORY & DATA
11Allocators & MemoryExplicit allocators, arena cleanup, and leak detection — no hidden allocation.
12Strings, Formatting & FilesStrings are byte slices, formatting is explicit, and file I/O needs an allocator.
13Structs, Enums & UnionsData modeling with struct, enum, tagged union, and exhaustive switch.
PHASE 5: TOOLING & INTEROP
14Build Systembuild.zig, build steps, and the zig build / run / test workflow.
15C InteropImport C headers with @cImport, link C libraries, and share types.
16Testing & Debuggingzig test, test blocks, safety checks, leak detection, and formatter.
PHASE 6: PRACTICE & DEMO
17Lab ExamplesRun and modify single-file practice demos for every lesson.
18Study ProjectsSmall composed projects that combine everything: algorithms and CLI tools.
PHASE 7: REFERENCE
19References & CompilersBrowser playgrounds, official docs, courses, and sample repositories.
Credits: Lesson content drafted with DeepSeek via Fireworks AI. References: free tutorials below.

Free References

For the full categorized table — online Zig playgrounds, official documentation, courses, and sample repos — see the References & Compilers page.