In past years, I've experimented union types in a low level language (Copper) and a higher level language. I got very interesting results but I'm currently experimenting a trimmed down version: just the option types. What is an Union Type? An union type is a list of two or more alternative types that a value can hold. For example: func f ( x : Int | String ) ... end the parameter x can be either a…
Some time ago, I tried to implement exceptions in my main programming language. It was an interesting experiment even if in the end I dropped everything. Before telling my journey, I'll give a bit more context on my view of error handling. Part 1 - Random Thoughts on Exceptions Correct error handling is hard , with or without exceptions. Handling Errors in Memory Allocation I use extensively a…
On Von Neumann architectures , programs are data, therefore they can modify their own code while running. Self-modifying code is mostly a matter of machine code even if some high level languages like LISP allow to manipulate their own code. So this practice was more common when developers wrote programs directly in assembly. Self-modifying code makes decompilation impossible in the general case…
I'm going to describe the various tricks I used to write fast compilers for my programming languages. By fast compilation, I mean compiling at least 500.000 lines of code per second (excluding blank lines and comments) on a single CPU core. Does it Matter? You may argue that compilation time is not important. After all, once released, who cares that a program took hours to build; as users, we only…
I'm starting this blog to talk about compilers, decompilers and programming language design. I have accumulated tons of random notes on these topics from my experiments through the years. Lot of them are worthless but few ones may be worth sharing; the good ideas as well as the bad ones. This is an hobbyist's blog, I am not an expert in programming language theory, there won't be any advanced…