Summary
This week I found myself digging through the code of c4, an implementation of C “in four functions”, by Robert Swierczek. c4 is dense, barely commented, and, frankly, strange. It’s unlike anything else I had come across in compiler land.
There are no structs in c4.c. It takes 39 VM cycles to execute my_program.c and 59822 cycles to executed c4-c4. c4 is a self-hosting language. A language that’s just small enough so you can build a compiler in it.
All the other instructions and their implementations are C at its … most C — very, very dense. Then there’s the fact that the base type is an integer. Or that it has a debug mode. Or…Isn’t it amazing what code is floating around, out there in the world, ready to reveal secrets and delight?