A worked example of copy-and-patch compilation

submited by
Style Pass
2024-12-23 16:00:21

I’ve been working on-and-off on a toy compiler. It started when I thought it would be a good idea to add extra language features to the C compiler I was working on. I eventually decided that was probably a poor idea, but that writing a completely new language made sense (?). Or was at least more fun!

In any case, I have been grappling on-and-off with that enjoyable black hole of a project, but it’s still deep in the “not working yet” phase.

and were running on a computer (charitably, let’s say a 486DX33) that ran at 33MHz, whereas the computer I’m sitting at now runs at 3.8GHz. That’s at least 100 times faster, and that’s before we even consider the fact that the modern one has 24 cores vs. the old one having exactly one!

And yet somehow, I’m able to read most of reddit/lobste.rs/this blog post while waiting for my C++/Rust/whatever to compile and link. Are today’s projects bigger? Sure, of course. Are they so much bigger and badly designed that we need to throw away something like a ~2400x difference in performance?

So! With that motivational speech in my mind, I checked my own toy compiler and found it, not surprisingly, disappointingly slow1.

Leave a Comment