Hacker News new | ask | show | jobs
by akireu 1611 days ago
Ah, I remember that one. Not a fond memory, either. The C-like language is a red herring: what you actually want is the codegen backend, and having any intermediaries between your AST and the codegen's IR will just add inefficiency and uncertainty. Ironically, there are parts of LLVM-like IR poking out of it: at page 43 of the spec pdf there's a table of instructions that have their counterparts in more or less any modern codegen.
1 comments

How do you feel about languages which have a mid-level intermediate representation, between the full language and the true IR?

For example: https://blog.rust-lang.org/2016/04/19/MIR.html

MIR isn't really a language of its own: it's a human-readable serialization of Rust compiler's lower-level AST, an artifact of the language's complexity. It's native to the compiler, so it doesn't need to be parsed, validated and compiled. So it isn't really relevant in this context.

Rust aside, I'm fine with using C as a target language, as it's well known and has all sorts of tooling, but inventing a whole new language with a custom syntax just to use a codegen is overkill, especially when there are more than a dozen projects that use SSA-based IR to great effect (from LLVM and golang to game console emulators).