Mitchell Hashimoto

Zig

This page collects my writing about the 🦎 Zig programming language.

Compiler Internals

An introduction to the internals of the Zig compiler. The articles currently cover an introduction of most of the compiler "frontend" -- the process from source code to just prior to machine code generation.

Note: These are the internals for the self-hosted compiler, also known as the "stage2" compiler. At the time of writing, not all of the stage2 components are in production use and are still mixed with "stage1" (C/C++) components.

  1. Zig Tokenizer
  2. Zig Parser
  3. Zig AstGen: AST => ZIR
  4. Zig Sema: ZIR => AIR

Comptime

A tour of comptime usecases in Zig.

  1. Conditionally Disabling Code
  2. Tagged Union Subsets

Other Topics