Ask HN: Online Compiler Courses?
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?
17 comments
[ 4.5 ms ] story [ 59.2 ms ] thread1. 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 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'm okay with paying, but my schedule wouldn't allow for a full-time middle-of-the-day course
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...
https://github.com/jamiebuilds/the-super-tiny-compiler
You can also check out my implementation in C at https://github.com/rmccullagh/letsbuildacompiler
Garbage collector is a part of compiler technology.
Or dig around a bit on http://t3x.org in general!
- https://www.edx.org/course/compilers
- https://www.youtube.com/playlist?list=PLDcmCgguL9rxPoVn2ykUF...
Not too much theory but from a nuts and bolts perspective I found it extremely approachable.