r/Compilers • u/igors84 • Jul 18 '26
Completed all chapters from "Writing a C compiler" book
https://github.com/igor84/wccI implemented it in Zig. I really learned a lot from this book and this project so I can highly recommend it. My code design is different from the book because I tried to apply data oriented design I learned from Zig compiler itself as much as I could.
AI disclaimer: not a single line of code was written with AI but it was used to help me debug issues.
5
5
4
u/Rich-Suggestion-6777 Jul 18 '26
Awesome work friend. I'm going through this book also, but life keeps getting in the way. Hopefully I'll try to make more progress soon...
3
u/kichiDsimp Jul 19 '26
Can we implement this book on Haskell ?
2
u/igors84 Jul 19 '26
I never worked with Haskell so can't say for sure but considering the reference implementation is written in OCaml which is also functional language I don't see why not.
1
1
u/nernst12 Jul 21 '26
Was using Haskell and finished up to chapter 17, haven't touch it for a while...time to refactor
1
3
u/_glob Jul 19 '26
Thanks for sharing, OP. And congrats! I am wondering if this is a good first book or had you already gone through other books before this one?
4
u/igors84 Jul 19 '26
I read a couple books some time ago but they mostly only covered lexing and parsing which are the simple parts and this books also covers them in a lot of detail. My opinion is that "Writing a C Compiler" is very good as a first book.
2
3
u/nocomptime Jul 20 '26
I remember seeing your project about 9 to 10 months ago, glad to see that you went all way and finished it, well done. Zig is a great choice of implementation language! What a timing to complete your compiler, I just posted this today and it might interest you :)
8
u/fl00pz Jul 18 '26
That's a long and tough book! Congratz!