Writing a C Compiler, in Zig (2025)

· coding books culture · Source ↗

TLDR

  • Author built paella, a C compiler in Zig, following Nora Sandler’s Writing a C Compiler book across 10 documented chapters.

Key Takeaways

  • Project paella covers a full introductory compiler pipeline: unary/binary ops, logic, variables, conditions, blocks, loops, functions, and linking.
  • Written as a dual-purpose learning exercise: learn Zig fundamentals and work through a structured compiler curriculum.
  • Series spans 10 chapters with individual writeups preserved as-is; author notes more chapters may follow if the book continues.
  • Nora Sandler’s Writing a C Compiler is the scaffold – paella is the Zig-native implementation on top of it.

Hacker News Comment Review

  • Commenters flagged that the author appears to have stopped partway through a later chapter (c19), citing frustration with low-level language constraints – the public repo shows the dropout point.
  • There is an open question about whether this project has long-term relevance to Zig’s toolchain: Zig currently relies on Clang/LLVM for its C frontend, and a native Zig-written C compiler could eventually change that dependency.
  • Confusion arose over Zig’s existing C compilation capability – commenters clarified Zig’s build system can invoke a C compiler but does not itself contain one, making paella a legitimate new implementation rather than redundant work.

Notable Comments

  • @fuhsnn: Points to c19.md in the repo where the author appears to have quit mid-chapter after frustration with lower-level language work.
  • @scatbot: Asks whether a Zig-native C compiler could reduce Clang/LLVM dependency in Zig’s own toolchain long-term.

Original | Discuss on HN