Hacker News new | past | comments | ask | show | jobs | submit login

On the related note, what would you guys recommend as an introduction to compilers, say for beginners?



Crafting Interpreters has been great. It starts with an AST-walking interpreter (in Java), so you get to focus on parsing and the simplest form of interpretation, and then it moves to a bytecode interpreter (in C) so you get to learn about compiling to a more primitive target via a lower-level language (much of which should translate to a "real" compiler). Very approachable, has lots of side-context and an entertaining style. The language you interpret was custom-designed for the course, which helps a lot, and resembles a simplified JavaScript without all the messy parts.


Author here. Also you can read the whole book online for free: http://craftinginterpreters.com/


Engineering a compiler is by far the best introductory book that is also modern.

Advanced compiling for high performance is one of not many good accounts of scheduling for non-toy architectures.

Muchnick's book is a good encyclopedia of optimisations although the code is unreadable and buggy.


cs4410[1] is really really good, and cse131[2] is basically the same thing but with videos. I highly recommend them both.

[1]: https://course.ccs.neu.edu/cs4410/

[2]: https://ucsd-cse131-f19.github.io/


Compilers books: I'd start with "Engineering a Compiler" by Keith Cooper and Linda Torczon. http://craftinginterpreters.com/ is also a pretty great, programming-oriented intro, which may be good to work through alongside. For more on the analysis & compiler optimization side, "SSA-based Compiler Design" (http://ssabook.gforge.inria.fr/latest/; GitHub Mirror: https://github.com/pfalcon/ssabook) is a good follow-up.

Further readings: Book recommendations in https://github.com/MattPD/cpplinks/blob/master/compilers.md#... as well as program analysis resources (in particular lattice theory, type systems and programming languages theory, related notation): https://gist.github.com/MattPD/00573ee14bf85ccac6bed3c0678dd...

Courses: I can recommend the following: https://github.com/MattPD/cpplinks/blob/master/compilers.md#...

Particularly (in alphabetical order--I think these are all great, so including highlights of what I've liked about them):

- IU P423/P523: Compilers (Programming Language Implementation) - Jeremy Siek, with the course book "Essentials of Compilation: An Incremental Approach" (pretty interesting approach, with programming language features developed incrementally having a fully working compiler at each step, cf. http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf; implementation language Racket),

- KAIST CS420: Compiler Design - Jeehoon Kang (good modern treatment of SSA representation itself, including the use of block arguments, https://mlir.llvm.org/docs/Rationale/Rationale/#block-argume..., as well as SSA-based analysis and optimization; Rust as an implementation language),

- UCSD CSE 131: Compiler Construction - Joseph Gibbs Politz, Ranjit Jhala (great lecturers, both Haskell and OCaml edition were interesting; fun extra: one of the Fall 2019 lectures (11/26) has an interesting discussion of the trade-offs between traditional OOP and FP compiler implementation),

- UCSD CSE 231: Advanced Compiler Design - Sorin Lerner (after UCSD CSE 131: for more on analysis & optimization--data flow analysis, lattice theory, SSA, optimization; fun extra: the final Winter 2018 lecture highlighted one of my favorite papers, https://pldi15.sigplan.org/details/pldi2015-papers/31/Provab...),

- UW CSE CSEP 501: Compilers - Hal Perkins (nice balanced introduction, including x86-64 assembly code generation, with the aforementioned "Engineering a Compiler" used as the course textbook).


Thank you so much for this comment. It's incredibly difficult to find modern compiler learning resources – when I ask, I often get disparaging comments about the dragon book and not much more.

Please, consider putting this list on your blog, or somewhere more visible than a HN comment.


> disparaging comments about the dragon book

How's that possible? It's a "keep it under your pillow" book. Whether you read it or not is a different question. I don't know anyone in the 'hood who wouldn't have.


I've been reading "Modern Compiler Design" currently, not too sure how beginner friendly it is though.

Also, haven't made it too far into the book so can't really give a recommendation either way.


Stanford Compilers Course




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: