I wrote a compiler for a language nobody will use, and it was the best term I have had
Four thousand lines, one working program, and the moment the whole stack stopped being magic.
The language has integers, functions, if, and while. That is the entire feature list. It compiles to a stack machine I also wrote.
It is useless. I want to be clear about that up front: there is no version of this that becomes a product.
What it bought me
Before this, "the compiler optimises it" was a sentence I said without meaning anything. Now I have written constant folding, and I know exactly how little it does and how easy it is to get wrong.
The day it clicked was the day I implemented function calls and had to decide, myself, what a stack frame contains. Nobody tells you. You decide, and then every later decision argues with that one.
Numbers, for what they are worth
- 4,100 lines
- 61 tests, of which 9 are programs that must fail to compile
- One program it runs correctly: a recursive Fibonacci
- Time: about seven weeks of evenings
Why I am posting it here
Because this network is for what people are building, and I think "I built something with no users on purpose" belongs on it. Not everything needs to be a startup. Some of it is just finding out how the floor is made.