3 ms·
I've played around a bit with this, and I was quite impressed by a hobby project. It's over-all a well designed language. I like the syntax, inspired by Scala
by retrac 4y ago
I've played around a bit with this, and I was quite impressed by a hobby project.
It's over-all a well designed language. I like the syntax, inspired by Scala (in which the Millfork compiler is written). Semantically, it's approximately equivalent to C. Though some things are a bit more verbose. Function pointers are a bit more limited and you can't pass complex types as parameters (only pointers). The language makes a number of practical concessions to its tiny target platforms. No default stack allocation of local variables, no auto-promotion of u8 to u16 etc.
Since the assembler and higher level language are the same thing in Millfork, it can switch fairly seamlessly between the two. You can specify which registers parameters are passed with in the function declaration, and whether individual functions are in Millfork or assembly, and you can switch between them within the function.
It's also an aggressively whole-program optimizing compiler. I'm not sure I've seen anything else quite like it, certainly not for the 6502 or Z80 processor, anyway. If you want, it will even take your hand-coded 6502 asm { } blocks, optimize those, and then find common sequences they share with compiled code, and factor them out into a common subroutine (if you've selected space rather than speed optimization, anyway).
Crazy to imagine what would have been written if a compiler like this existed in the 80s. (It couldn't have, of course, at least based the memory footprint on my desktop the compiler takes to run with full optimization!)