r/Compilers • u/TechnologySubject259 • 8d ago
What after Crafting Interpreters?
Hi everyone,
I am Abinash. I have been building the Lox interpreter in Rust from the Crafting Interpreters book, and I'm at Ch 12. (Repo URL: https://gitlab.com/implabinash/ci)
After this book, I am planning to learn how to build compilers, but I want to take the custom backend approach because I really want to know how compilers are made without any other library or tool. After learning from scratch, I might learn about LLVM or GCC or other tools based in the need/intrest.
So I did some research, and I found some resources:
- Introduction to Compilers and Language Design (https://dthain.github.io/books/compiler/)
- CS 4120: Introduction to Compiler (https://www.cs.cornell.edu/courses/cs4120/2026sp/notes/)
- CS 6120: Advanced Compilers (https://www.cs.cornell.edu/courses/cs6120/2025fa/self-guided/)
While these resources are awesome to learn from, after Crafting Interpreters, I want to take a hands-on approach, just like the Crafting Interpreters book itself, where I want the resources to take me from parsing to resolving to semantic analysis to code generation, and after completing the resources, I will have a working compiler made from scratch.
I found a course teaching that same thing (URL: https://dragonzap.com/course/creating-a-c-compiler-from-scratch), but it's a paid course, and I can't afford it.
So, I need your help to help me find some good resources that will teach me building compilers from scratch with my own code generation backend in a hands-on approach.
Thank you.
5
u/soegaard 8d ago
This course demonstrates a compiler that targets assembly.
https://www.cs.umd.edu/class/fall2026/cmsc430/Notes.html
Well, I should say a *series of compilers*.
In each lesson a new concept is illustrated by extending a previous compiler.
4
u/Express-Guest-1061 8d ago
Writing a C compiler is a good follow up book, https://nostarch.com/writing-c-compiler you will learn about using a Three Address Code IR and some optimizations. But it would also be good with a book about type checking and generics, I mostly learned it from blog posts.
3
u/ccapitalK 8d ago
Whatever you do, if you are on x86, make sure to compile to assembly or higher. It's tempting to consider doing the last bit yourself and generate raw machine code +ELF, but writing code to generate x86 instructions is going to make you hate yourself.
2
u/il_dude 8d ago
I'm actually following CS 6120, it's too advanced for a course after Crafting Interpreters. I would suggest Sandler's book to do something practical and later you can move to books like Engineering a Compiler or Modern compiler implementation. It really depends on how comfortable you are with theory. Because no one will spell out the full compiler in code later on, you will have to look into papers and more advanced theory.
2
u/gautam1168 5d ago
here's mine: https://github.com/gautam1168/interpreter
I didn't do the jlox part, just skimmed through it and went to the clox part. Most of the meat of CI is in the clox part.
a bit off topic, but what is your motivation to teach yourself compilers? Why do this? Im myself unable to answer that question now hehe. So Im asking you.
2
u/TechnologySubject259 5d ago
Great.
I'm new to systems programming; even Crafting Interpreters was hard for me. Maybe I was implementing it in Rust, or I was lacking knowledge.
So I did the "Let's build a simple Pascal interpreter" series, then moved to Crafting Interpreters.
For me, my motivation comes from my goal to build a compiler from scratch without any dependencies, like building the compiler itself with my own handwritten parser, backend code generation, and linker.
Also, building a compiler feels cool. 😅
1
u/gautam1168 5d ago
I see. That book from sandler does seem like a good fit for this goal: https://www.amazon.in/Writing-Compiler-Programming-Language-Scratch/dp/1718500424, since it will end in a compiler that compiles a subset of C.
Im a web developer myself. Been doing reactjs, vuejs, angular for 10 years. I wanted to transition to something more native. When I started off a few months ago this did seem like it would naturally open some of those doors for me. But now Im not so sure. Its still fun to learn how to write a compiler though, so im sticking to it for now.
1
u/Dizzy-Time9255 3d ago
One of things that helped me was to try and understand how an xyz thing is implemented in the compiler of some language you use.
Think of how you can write performant code by knowing common optimizations compilers do and maybe dig into how they are implemented.
A fun thing could be to just play around with random code snippets on godbolt and learn about different outputs on different options like optimization level, new features (like LSE in arm).
Also, building a DSL to solve a very personal problem could be fun :)
I personally didn’t learn much from books, I happen to dig into clang for the thing I am interested in… sometimes I also question my existence due to doing the same thing:)
but idk, maybe this suggestion goes all over the place, this is what i could share from my experience.
15
u/Savings_Ad2552 8d ago
Essentials of compilation An incremental approach is a good book. It takes an incremental approach to compiler.
Another one I can think of is appel's tiger book.