Today it’s clear that representing optional values with Null was not the best idea. Several modern languages model this problem with explicit nullable types or Option Monad (after the Haskell Maybe Monad). As Option in Scala has influenced my programming style heavily over the last years, I wanted to compare how other languages deal with this. I did not include Groovy although it was one of the first (the first?) JVM language to safely dereference null values because I currently have no interest in Groovy.
Continue reading Comparing Optionals and Null in Swift, Scala, Ceylon and Kotlin
Disclaimer: I only know web frontend/backend and mobile development with several teams. So everything I say needs to be seen in this context.
In beginning of the 90s I was writing internet code in C directly using TCP/IP as an ‘abstraction’ layer. Bugs were plenty and development was a pain. Then Java arrived and made development much more pleasant. Java with exceptions created nicer to read exception stack traces than C did with core dumps and also prevented many common C bugs. Continue reading The Case for a New Programming Language
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!