OK, you beat me

Moderator: Ras
OK, you beat me
If you write a code generator, you have complete control over the code that you generate. It should not be too hard to avoid generating illegal code (exhibiting undefined behaviour). You just have to get it right once for all small pieces of code that you generate. This is much harder if you write a large program in C yourself.Ras wrote: ↑Tue Dec 17, 2024 10:19 pmThe problem is that a bug in the code generator may lead to undefined behaviour. The main problem with that is that it may not even manifest with current C compilers, so all tests would pass - and then suddenly, after a C compiler update, the generated code breaks (stuff like that did happen before).
Yeah, and then rely on the C compiler to somehow optimise such probably pretty awful C code, resulting from the "small pieces" approach and the inherent language mismatch. I think Rust wouldn't be competitive in terms of speed anymore, not to mention that compilation times are already an issue. Also, Rust devs would have to think in terms of C code, which is also not what they want.
Easier and faster. The only minor downside is that you lose targets without LLVM - but if these were popular, they would have LLVM support anyway.But I guess it will be still easier to generate LLVM IR.