←back to thread

143 points todsacerdoti | 2 comments | | HN request time: 0.404s | source
Show context
tiu ◴[] No.43594898[source]
I just got over writing 2 (well 2.5) toy compilers and I think a lot of the material in the compiler-teaching space lack some subtle developmental aspects.

I wish there was a course designed somewhere which talked about more ingrained issues: how to structure/design the AST[0], buffer based vs noncontextual tokenization/parser design, index handling and error sync in the parser, supporting multiple codegen architectures, handling FFI, exposing the compiler as an API for external tooling, namespaces and linkage handling etc. etc. etc.

It is refreshing to see how Carbon designed some of its components (majorly the frontend, yet to take a look at the backend) as it touches on some of the subtleties I mentioned. If someone is starting out on writing one, I would recommend taking a look at it or any of the talks.

Always nice to see new material coming up. A few resources that I would like to mention would be dabaez's compiler course, Khoury college's compiler course (in Rust, previously i think and Ocaml), Nora Sandler's book as well as http://compilerbook.org; Which I consider to be the best guide out there for writing small learning compilers, the videos are good as well.

[0]: Some related content that I enjoyed reading: https://lesleylai.info/en/ast-in-cpp-part-1-variant/

replies(3): >>43595603 #>>43595652 #>>43602829 #
1. yencabulator ◴[] No.43602829[source]
The compilerbook link is broken in multiple ways, but www.compilerbook.com redirects to https://www3.nd.edu/~dthain/compilerbook/
replies(1): >>43603044 #
2. tiu ◴[] No.43603044[source]
Yes, thank you. That is the Douglas Thain book I meant. (compilerbook.org seems to work for me, only broken thing would be the semicolon).