WCC:


After a lot of work I finally completed Zig implementation of all the chapters from “Writing a C compiler” book, with extra features. Code design is quite different from what the book suggests since I tried to apply all I learned from data oriented design from Andrew Kelley and Zig compiler itself.

I really learned a lot from this book and this project especially about later compiler passes.

Supported Zig versions

Zig 0.16

AI / LLM usage disclosure

Not a single line of code was written by AI. It wasn’t even used as an autocomplete tool. But AI was used. Total usage amounted to $35 of Codex plus some free usage of web chat interfaces of ChatGPT, Gemini and Grok. Only used these prompts:

  • Find the mistake in generated asm file - 90% of all prompts :slight_smile:
  • Find in the code where that mistake was made and just explain it to me
  • Test from the book is not passing with my compiler. Compare to reference compiler and explain to me what I did differently.
  • I also asked a few times about some corner cases in C standard and what is idiomatic way to do something in zig like “how to iterate through the slice backwards”.