Compiling a small Scala subset into x86-64 asm
mykolav.github.ioHi HN!
I wrote a toy compiler.
Here I tried to describe it in detail: https://mykolav.github.io/coollang-2020-fs/
And the repo is here: https://github.com/mykolav/coollang-2020-fs
The project was purely for fun and to other people it's, honestly, just another toy compiler. But there are a couple things that should set it apart.
1) It compiles down to x86-64 assembly. Then invokes GNU as and ld to produce a native executable. To me personally, this is much more rewarding than emitting MIPS asm and using an emulator to run it. I also prefer emitting asm to emitting, for example, C -- at the very least, it forces the developer to figure out converting expressions into asm. That really drives home the point how much work high level langs do for us.
2) The lang is simple but not too simple. A lot of mini-compilers have languages with functions, primitive values and pretty much nothing else. Whereas this project's lang has classes, inheritance, virtual dispatch, and even a very simple form of pattern matching.
3) The write-up describing the project. Final sections contain a number of links to awesome compiler-learning resources. Every major topics is covered only by one or two links. Obviously, I had to make these sections opinionated, but give it a chance, it might click for you too.