Introduction

Why Zig?

Zig is a systems programming language designed for robustness, performance, and maintainability. It aims to be a better C -- with modern ergonomics but without hidden control flow, hidden allocations, or undefined behavior.

  • No hidden control flow -- No operator overloading, no hidden function calls. What you see is what the machine executes.
  • Compile-time execution -- Zig's comptime lets you run arbitrary code at compile time, replacing the need for macros and code generation.
  • Manual memory management done right -- Allocators are explicit and passed as parameters. No global allocator, no garbage collector.
  • C interop -- Zig can import C headers and call C functions directly, with no bindings or FFI boilerplate.
  • Safety without runtime cost -- Bounds checking, null checking, and undefined behavior detection in debug builds, stripped in release builds.

The Story

Zig was created by Andrew Kelley, who started working on it in 2015 after becoming frustrated with C and C++ while working on performance-critical systems. The first public release came in 2017.

Andrew's goal was a language that could be used everywhere C is used -- operating systems, embedded systems, high-performance computing -- but with a focus on making the programmer's intent clear and catching bugs at compile time rather than at runtime.

The Zig Software Foundation was established to support the development of the language and its ecosystem.

Who Uses Zig

Zig is gaining traction in systems programming and infrastructure:

  • Bun -- the fast JavaScript runtime and toolkit is written in Zig.
  • TigerBeetle -- a high-performance financial transactions database.
  • Mach Engine -- a game engine built on Zig.
  • Uber -- uses Zig for network proxy infrastructure.

Zig is also used as a drop-in C/C++ cross-compiler, since its toolchain includes a complete C compiler with cross-compilation support out of the box.

What You Will Learn

This course contains 12 lessons organized into 6 chapters:

  1. Foundations -- How Zig programs are structured, variables, types, and printing output.
  2. Control Flow -- Conditionals with if/else and switch. Loops with while and for.
  3. Functions -- Function declarations, error unions, and error handling.
  4. Data Structures -- Arrays, slices, and structs with methods.
  5. Memory -- Pointers, allocators, and manual memory management.
  6. Advanced -- Compile-time execution, optionals, and tagged unions.

Each lesson explains a concept, demonstrates it with code examples, and gives you an exercise to practice.

Let's get started.

Next →