Way back in 2011 I started hacking around with the Coffeescript transpiler, for example seeing what it took to add Ruby’s overridable comparison operator to the language:
I ran a meet up group that made a speedy journey through SICP. The final two chapters of that book always felt like they required a lot more time than was easy to give them. So earlier this year I took a week out to stay in a beautiful house in the Austrian alps with SICP, pen and paper, and a goal: read chapters four and five of SICP and do the exercises!
As a counterpoint to exercise 5.51, modify the compiler so that it compiles Scheme procedures into sequences of C instructions.
This exercises exemplifies why I love SICP - it's a mentor that shows sets you genuinely challenging tasks, which you can rely on giving you insights you'll find useful for as long as you write code.
I’ve got a lot out of the process so far, and I want to share it. To say the least it’s way too much for a single post. So I’m going to blog it every two weeks, going retrospectively over the first steps. I’ll introduce parsing and compiling bit by bit, without any required computer-science or C background: just the way I learned it!
I’ll cover the following:
- Compiling an interpreted, dynamic language. HUH?
- Compiler basics
- Representing values at runtime
- Compiling statements
- Compiling operators
- Compiling functions
- Compiling exceptions
- Garbage collection
- Event driven runtime