I’m late to the game, reviewing ‘How to Create Your Own Programming Language’ (HTCYOPL) but with my renewed interest in creating programming languages I thought I’d give it a go.
First it looks rather thin on content, with quite some pages but huge fonts and not a lot of content on each page. But don’t let yourself fooled, there is a lot of content and it is sufficient.
HTCYOPL is not only a book explaining the basics of creating a programming language. It does so by using an example language called ‘Awesome’ and another one called ‘Mio’. This makes the book much more interesting compared to standard compiler builder books. It also makes it easy to start your own language with ‘Awesome’ as a starting point. All of the book is accessible to the average reader.
The books starts with an overview of components of a compiler chain and then goes into Lexer (creates tokens from source code), Parser (creates an AST from the tokens), Runtime Model and Interpreter (executing the AST). My university days where I’ve learned about compilers are long over, so basically with no knowledge I’ve cruised through this parts and had several enlightening moments. Although the book could stop there, as you now have all you need for your language, it dives into more intersting topics like virtual machines and compiling your language with LLVM.
HTCYOPL helped me tremendously to understand the different parts of a programming language and how they interact to compile from source code to byte code. With HTCYOPL in my hands I’ve started to look into Kotlin internals and – I could read and understand parts with tokens, parsers and ASTs. So for me the book was a win and I’d recommend the book to everyone who wants to dabble into programming languages and like me has no clue. Write the next Ruby!