The Siren Song of Little Languages
wilfred.me.uk
wilfred.me.uk
We have no shortage of introductory texts on writing compilers or interpreters, but often these seem to spend hundreds of pages on lexing and parsing, so you can read your source code and turn it into some beautifully designed AST, and then about five pages on subsequently turning that AST into something useful. What they do have is usually very simple examples implementing local variables and maybe a basic control structure or two in an imperative language.
There is relatively little available at a more intermediate to advanced level. Which books describe in detail how to implement different kinds of runtime infrastructure, such as garbage collection or exception handling or dynamic loading of shared code? What about different strategies for implementing the basic behaviour of the program, such as compiling with continuations instead of using nested stack frames for everything? Suppose you want to implement closures and you're considering how they could interact with some new memory model you're using; where do you look for advice and learn about any relevant prior art? What optimisation strategies have been discovered that could be useful once you have a simple first implementation?
There are answers to these kinds of questions out there, but often they are scattered among academic papers, videos from small conferences or ten-year-old discussions on twenty-year-old discussion websites. There are a few books addressing some of these points, but they are relatively obscure.
- "I want to build a house"
- "OK, what kind of house"
- "Preferably red"
"Let's Build a Compiler", by Jack Crenshaw
https://compilers.iecc.com/crenshaw/
"Compiler Construction" by Niklaus Wirth
http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf
Then you can follow up with "Project Oberon (New Edition 2013)" by Niklaus Wirth, for the whole stack experience
(By shocking coincidence, the same courses often use ML-family functional languages as the implementation language...)
No it doesn't because I did not need that yet. Here is how your little language can get its first user: don't try to conquer the world with it right away. Conquer your own desktop first.
There was a lot to like about it, and how ahead of its time it was: safe parallelism, a powerful type system, extensible syntax; but ultimately its ambition and overall weirdness in how it looked made it hard to digest.