DEV Community

Discussion on: ELI5: Why self-host a compiler?

citizen428 profile image
Michael Kohl

So, there is no direct influence on the generated code, like how a multi-pass compilation process can build a more complete image of the program for more aggressive optimizations?

I guess there is no general answer to this. On the one hand, nobody knows your own language and what optimizations it will benefit from better than you. On the other hand building in an established language like C gives you many optimizations on the compiler itself for free.

I still feel like that sounds like a side-project that could dictate ongoing development, not the canonical implementation

Presumably one builds a new language because of a dissatisfaction with all existing alternatives. So if the space you're aiming for is systems programming (Rust, Go to a certain extent) than not self-hosting seems a bit odd. The languages I mentioned before generally are on a relatively different level of abstraction than the ones they were implemented in (and often work as interpreters, not compilers).

Thread Thread
deciduously profile image
Ben Lovy Author

dissatisfaction with all existing alternatives

That's a satisfying answer, thanks. You do it because you think you're doing it better than C would have.