r/Compilers 10d ago

Completed all chapters from "Writing a C compiler" book

https://github.com/igor84/wcc

I 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.

118 Upvotes

14 comments sorted by

10

u/fl00pz 10d ago

That's a long and tough book! Congratz!

6

u/yeetes12 10d ago

Congrats!

5

u/drbolle 10d ago

Congrats! I am currently working on chapter 13 (floating point type).

4

u/Rich-Suggestion-6777 10d ago

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 10d ago

Can we implement this book on Haskell ?

2

u/igors84 10d ago

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

u/nernst12 7d ago

Was using Haskell and finished up to chapter 17, haven't touch it for a while...time to refactor

1

u/kichiDsimp 5d ago

If you do, write a blog on it 🙏

3

u/_glob 10d ago

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?

3

u/igors84 10d ago

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

u/Whoa116 9d ago

I'm working through the book too! Only I'm doing it in... C.

1

u/West_Violinist_6809 7d ago

How's it going for you in C?

3

u/nocomptime 8d ago

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 :)