Outline updated November 2026

Foundation21 hours delivered over 3 daysLive, online

Request this course

Zig Essentials

Class Duration

21 hours of live training delivered over 3 days.

Student Prerequisites

  • Prior programming experience in some language (C, C++, Rust, Go, or similar is ideal)
  • Comfort with the command line and a compiler-based workflow
  • No prior Zig experience required

Target Audience

Description

Zig Essentials teaches the Zig language and toolchain, a systems language that improves on C. Zig adds optionals and required error handling, and it passes allocators as explicit parameters. Students start with data types, control flow, code organization, and memory management with defer and errdefer. The course then covers comptime, allocator design, and the std.Io interface. It ends with the build system, testing, safety-checked build modes, and C interop.

Learning Outcomes

  • Build, run, and test Zig programs with the Zig toolchain and build system.
  • Explain what sets Zig apart and where it is a good fit.
  • Apply Zig's memory control, optionals, and error handling.
  • Choose, compose, and test allocators, and detect leaks in tests.
  • Use comptime for generic, reflective, zero-cost code.
  • Write code against the std.Io interface.
  • Run tasks asynchronously and concurrently with futures and groups.
  • Select build modes and explain the safety checks in each.
  • Plan where Zig can work alongside or replace C in an existing codebase.

Training Materials

All students receive comprehensive courseware covering all topics in the course. Courseware is distributed via GitHub in the form of documentation and extensive code samples. Students practice the topics covered through challenging hands-on lab exercises.

Software Requirements

Students will need a free, personal GitHub account to access the courseware. Students will need permission to install Zig 0.17 and Visual Studio Code (with the Zig language extension) on their computers. No separate C compiler is required, because the Zig toolchain compiles the C code used in class. Also, students will need permission to install Visual Studio Code extensions. If students are unable to configure a local environment, a cloud-based environment can be provided.

Training Topics

Why Zig?

  • What Zig is
  • Problems Zig solves
  • Zig compared to C
  • Zig compared to other languages
  • Zig Zen
  • Release cadence and the road to 1.0

Getting Started

  • The Zig toolchain
  • Hello, Zig!
  • Coding and debugging in VS Code
  • The Zig standard library
  • Zig source files
  • Cross-compilation

Language Features in Hello Zig

  • Importing from the standard library
  • Constants
  • A public main function
  • The std.process.Init parameter
  • Allocator, Io, and arguments from Init
  • The try keyword
  • Error union types
  • Format strings and format arguments
  • Comments

Zig Project Scaffolding

  • Creating an executable project
  • Creating a library project
  • Build and run
  • Build and test

Console Apps

  • Buffered terminal output
  • Format specifiers
  • Anonymous struct literals as format arguments
  • Reading terminal input
  • String comparison
  • while loops
  • Error handling

Data Types and Data Structures

  • Integers and floats
  • Arrays, pointers, and slices
  • Optionals
  • Structs
  • Enums
  • Unions and tagged unions

Variables

  • Variable naming rules
  • Container-level variables
  • Compile-time vs. run-time variables
  • Local variables

Control Flow

  • Expressions and operators
  • while and for loops
  • Labeled blocks and loops
  • break and continue
  • if statements
  • switch statements
  • try and catch
  • defer and errdefer

Functions

  • Defining and calling functions
  • Passing parameters
  • Immutable vs. mutable parameters
  • Importing functions from other Zig files

Strings

  • Strings as UTF-8 byte slices
  • String literals and sentinel-terminated arrays
  • Buffers
  • Printing formatted strings
  • Capturing strings from console input
  • Copying and comparing strings with std.mem

Program a Zig "Object"

  • Compared to C, C++, Python, and JavaScript
  • Files as structs
  • Data fields and constant fields
  • Methods and the init/deinit convention
  • Error sets as part of an API
  • Dynamic memory allocation for struct members

Errors and Error Handling

  • Inferred, explicit, and merged error sets
  • Error union types and try
  • Handling errors with catch and switch
  • errdefer and partial-initialization cleanup
  • Error return traces

Memory Control and Allocators

  • No hidden allocations
  • Memory control vs. memory safety
  • The Allocator interface
  • Passing allocators as parameters
  • Page, arena, and fixed-buffer allocators
  • General-purpose allocators
  • Leak and double-free detection with SafeAllocator
  • Lifetime-scoped allocation with arenas
  • Heap allocation failure
  • Lifetime and ownership
  • Optionals and optional pointers
  • Null references
  • Writing a wrapping allocator
  • Leak detection with std.testing.allocator
  • Allocation failure injection in tests

Comptime

  • Types as first-class values
  • comptime parameters, variables, and blocks
  • Generic functions and data structures
  • Reflection with @TypeOf and @typeInfo
  • Lookup tables at compile time
  • Branch quotas and comptime limits
  • Comptime vs. macros and templates

I/O with std.Io

  • Passing Io as a parameter
  • Io.Reader and Io.Writer
  • Explicit buffering
  • Files and directories through Io
  • io.async vs. io.concurrent
  • Futures with await and cancel
  • Managing many tasks with Io.Group
  • Cancellation and error.Canceled
  • The defer-cancel pattern
  • Io.Threaded as the default
  • Experimental backends such as Io.Evented
  • Writing Io-generic libraries

The Zig Build System

  • build.zig and build.zig.zon
  • Declaring dependencies with zig fetch
  • Creating modules and executables
  • Cross-compilation targets
  • Adding C sources and linking C libraries
  • C headers via the translate-c package

Testing

  • Built-in tests with test "name" { ... }
  • What can be tested
  • Asserting with try expect
  • std.testing.expectEqual, expectError, and expectEqualStrings
  • Testing Io-generic code
  • Built-in fuzzing with zig build test --fuzz

Build Modes and Safety

  • Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall
  • Bounds and overflow checks
  • Null unwrap and unreachable checks
  • Illegal behavior vs. undefined behavior
  • Choosing a build mode

Private team training

Bring this course to your team

Tell us about your team and we will tailor this outline to your tools, stack, and schedule. Courses can also be combined into a longer program.

  1. Tell us what you needYour tools, stack, team size, and timeline.
  2. We send a proposalA course or program, an outline adjusted to your team, and possible dates.
  3. Your team trains liveOnline or on-site, with courseware for every student.

Prefer to talk? Call +1 434-509-6890 or email help@cloudcontraptions.com.

We reply within 1 business day.

Training partner?