Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Online Compiler Courses?
81 points by _bxg1 12 months ago | hide | past | favorite | 17 comments
Compilers are one of the few major topics that was never covered in my CS education, but I've really taken an interest in them lately. They also seem like something that really would benefit from a structured curriculum.

Any recommendations for an online course?




I’m on mobile, but three recommendations for books/resources are:

1. Crafting interpreters. There’s plenty of hn discussion on it and it was recently completed.

2. Writing a compiler in go. There’s also a book on interpreters that goes along handily with it from Thorsten ball as well.

3. Build your own lisp

There’s also plenty of traditional textbooks such as the dragon book. I don’t have any lectures or videos on hand, but I’m sure teach yourself CS has a recommended course on it.


I saw Crafting Interpreters but I wasn't sure if it really covered compilers or focused mainly on interpretation (I know there's a lot of overlap, but still).

I have done basic Lisp interpreters before in JS/Python and even did a bit of compilation from Lisp to JS, but those feel like they're only scratching the surface because a) Lisp is so easy to parse it almost feels like cheating, and b) using a dynamic language as a target means you can lean on several of its built-in features instead of implementing them from scratch

So for example, I'd really especially like to learn more about representing ASTs and parsing an arbitrary context-free grammar, and maybe even some basic type-system stuff if that isn't too far out of scope

Edit: Turns out what I'd seen before was "Essentials of Interpretation", a Udemy course. I will say I tend to prefer the course format over a book.


I just recently finished Crafting Interpreters. The third part of the book covers a bytecode virtual machine and overlaps with compiler concepts. Perhaps Bob didn't put "compiler" in the title since the bytecode VM still requires the source code to be present during runtime. Even if it doesn't teach how to produce a "compiled file" in some form, it is still valuable as an approachable transition from simpler tree walk interpreters.


Here's a great YouTube series where a developer codes, step-by-step, a pretty fully-fledged programming language: https://www.youtube.com/watch?v=wgHIkdUQbp0&list=PLRAdsfhKI4...

Not too much theory but from a nuts and bolts perspective I found it extremely approachable.


For a great introduction tutorial, check out "Let's build a compiler". It's an excellent and simple introduction to compiling and emitting code.

You can also check out my implementation in C at https://github.com/rmccullagh/letsbuildacompiler


Here is the garbage collector course from the FB engineer. http://dmitrysoshnikov.com/courses/essentials-of-garbage-col...

Garbage collector is a part of compiler technology.


Just a book, not a full course: http://t3x.org/t3x/book.html

Or dig around a bit on http://t3x.org in general!



There is a GitHub project I've used as reference a couple of times, written in JS.

https://github.com/jamiebuilds/the-super-tiny-compiler


Although not exactly an online course, my compilers professor released his book for free online. It walks you through all the steps of building a compiler and is an invaluable resource for me. You can find it at www.compilerbook.org


Update: feel free to continue adding recommendations but I started reading Crafting Interpreters and it seems like the perfect difficulty/depth balance, so I'll probably stick with that.


As for video courses, I have Alex Aiken's compilers course on my list. It seems a bit more advanced, and I'm still on introductory material, so I haven't started with it yet.


Not already mentioned include the llvm tutorials, graalvm tutorials for building a truffle language and david beazely runs a paid, expensive course that seems pretty good!


Wow, Beazley's course appears to be live, not a video series

I'm okay with paying, but my schedule wouldn't allow for a full-time middle-of-the-day course


I took both his SICP course and compilers course back-to-back, and I highly recommend both of them.

Also, sometimes people need something to get them hooked, and kickstart a habit of working on a project. A compilers book is too heavy there. For that I would recommend what got me started down this rabbit hole, which was Gary Bernhardt’s “Compiler from scratch” screencast (paid, not free, but his half dozen “from scratch” casts are well worth it). In 20 minutes you’ll be taught how to build a regex-based lexer, a recursive descent parser, and do some very basic output generation.

I wrote a series of blog posts about using those techniques to implement an alternative syntax for C: https://gist.github.com/cellularmitosis/d4f8d92886061f1629b1...

If interpreters is your thing, I’ve hacked around with those a bit as well: https://gist.github.com/cellularmitosis/a46efbf32544cde3a1d1... https://gist.github.com/cellularmitosis/d8d4034c82b0ef817913...

I also maintain a list of links to simple CPU designs, simple compilers, and simple interpreters (for study): https://gist.github.com/cellularmitosis/1f55f9679f064bcff029...

Edit: ah I forgot the compiler from scratch link! I also forgot that particular video is free!!! https://www.destroyallsoftware.com/screencasts/catalog/a-com...

Edit: also, a (broken) math interpreter which demonstrates how to use graphviz to visualize the AST https://gist.github.com/cellularmitosis/fa41234f641ce55a7374...

Edit: also, don’t be afraid to skip the lexer and parser and just start working with an AST data structure. Whatever it takes to get started! https://gist.github.com/cellularmitosis/074730ddde770f4ac694...



The final chapter of SICP builds a simple compiler.




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

Search: