Book to learn about compilers?

#1

Hello,

it might be a bit out of topic, I would like to contribute to the development of rust itself, and I’m wondering if people in the community has good books regarding the way of working of a compiler.

Is " Compilers: Principles, Techniques, and Tools (2nd Edition)" enough, or should I look for other books/tutorials?

Many thanks,

Adonis

#2

I recommend Engineering a Compiler(EAC for short). In my opinion, it has better balance of frontend and backend compared to Dragon Book, which is frontend-biased.

EAC 1st edition came out in 2003 and 2nd edition in 2011. Supposedly 3rd edition is in the work. 2nd edition is better and more up-to-date, but 1st edition is okay, it’s not too outdated.

1 Like
#3

Not sure of your level of experience - if you’re starting totally from scratch (like me!), I’d definitely recommend Crafting Interpreters, since it’s both free and very low on jargon.

It focuses more on interpreted languages rather than native compiled languages, but the second half of the book (which is still a work in progress) is about compiling to bytecode for a VM - a lot of the concepts there should be transferable.

2 Likes
#4
#5

If you want to know specifically how rustc works and how to contribute to it, you should read The Rustc Guide, which is the official resource.

1 Like
#6

Personally I like PLP (https://www.cs.rochester.edu/~scott/pragmatics/) as a general reference.

The #langdev channel on the community discord has some additional resources in a pinned comment.

1 Like
#7

I would also add Crafting Interpreters and Build Your own Lisp for people who like to project-based learning.

1 Like