Free Zig Tutorials

25 free, hands-on Zig lessons from first lines of code to advanced patterns. Run every example directly in your browser — no install, no signup.

intermediate

Error Handling

Master Zig error handling — use error unions, error sets, try/catch, and errdefer to write robust code that fails gracefully without exceptions.

22 min read
1 prerequisites

Memory and Allocators

Understand Zig memory management — compare stack vs heap allocation, use allocator interfaces, and avoid leaks with explicit manual memory control.

28 min read
1 prerequisites

Zig Comptime — Compile-Time Programming Guide

Zig comptime tutorial — learn compile-time evaluation, comptime parameters, type reflection, and how to write generic zero-cost abstractions. Free tutorial with runnable examples.

25 min read
2 prerequisites

Optionals and Unions

Learn the Zig optional type and null safety — use ?T to represent nullable values, unwrap safely with orelse and if, and match on tagged unions.

22 min read
1 prerequisites

Slices and Iteration

Master Zig slices and iteration — use fat pointers for safe array views, iterate with for loops, and leverage std.mem utilities for searching and splitting.

22 min read
1 prerequisites

Pointers And References

Master Zig pointers — take addresses with &, dereference with .*, understand *T vs [*]T vs []T, and pass data by reference for efficient code.

28 min read
3 prerequisites

String Handling

Learn Zig string handling — work with []const u8 byte slices, compare and search strings, iterate bytes, and build strings with std.fmt.

25 min read
4 prerequisites

Generics And Anytype

Learn Zig generics and anytype — write reusable, type-safe functions using comptime type parameters with zero runtime overhead.

25 min read
4 prerequisites

Zig File I/O

Read and write files in Zig with std.fs — open file handles, use buffered readers and writers, manage directories, and handle I/O errors explicitly.

20 min read
4 prerequisites

Data Structures

Use Zig data structures — build dynamic collections with std.ArrayList, store key-value pairs in std.HashMap, and create your own generic types.

25 min read
5 prerequisites

Zig Packaging and Modules — Project Structure Guide

Structure Zig projects with modules — use @import for file-based modules, control visibility with pub, and manage packages with build.zig.zon. Free tutorial with examples.

22 min read
5 prerequisites

advanced

Async I/O

Learn non-blocking I/O, event loops, and polling-based concurrency patterns in Zig for high-performance applications

25 min read
1 prerequisites

Testing

Write Zig unit tests using built-in test blocks and std.testing — run tests with zig test, assert values, and detect memory leaks automatically.

22 min read
1 prerequisites

Zig Build System — build.zig Tutorial

Learn the Zig build system — configure build.zig for compilation, testing, and dependencies without Make or CMake. Free hands-on tutorial with runnable examples.

25 min read
1 prerequisites

Zig C Interop — Call C from Zig Guide

Call C from Zig with zero overhead — use @cImport to include C headers, link C libraries, and pass data between Zig and C seamlessly. Free tutorial with examples.

28 min read
1 prerequisites

Capstone Project

Build a complete Zig command-line tool — combine allocators, error handling, slices, structs, and testing into a real data processing utility.

30 min read
1 prerequisites

Interfaces and Vtables

Implement Zig interfaces using vtables — use tagged unions for closed dispatch and function pointer structs for open, runtime polymorphism.

25 min read
5 prerequisites

SIMD and Vectors

Use Zig SIMD with @Vector — perform element-wise operations, reduce vectors to scalars, and write data-parallel code targeting real CPU instructions.

25 min read
5 prerequisites

Error Handling Patterns

Go beyond basic Zig error handling — define custom error sets, use errdefer for cleanup, merge error sets, and switch on specific errors for recovery.

25 min read
5 prerequisites