Hacker News new | ask | show | jobs
by the-alt-one 1593 days ago
So why is it a transpiler and not only a compiler?
2 comments

Because it compiles to a programming language of same or higher level of abstraction.
Are the techniques used different in such a case? Shouldn't it just be the same?

Basically F(C) = R such that eval_C(C) = eval_R(R) where = means something like "discernible effects".

Wouldn't an optimization pass be a transpiler then?

It’s just a slightly more descriptive term that gives you the information that it’s high-to-high.

It’s like saying cheese burger instead of burger - it’s a little more info. It’s not saying that it’s not a burger as well, or that the techniques involved aren’t broadly the same.

A bunch of things a compiler "going downwards" needs to do don't apply, e.g. you don't need to worry about registers and things like that. And there's potentially more complex concepts to map to instead of just breaking source-language concepts down.

Haven't seen that terminology applied to individual passes.

Most compilers don't have to worry about registers nowadays, since they compile to LLVM or C.
It was just an example of a task. Also, "compile to LLVM" is very much "LLVM is part of the compiler, and thus worries about registers". Compile to C is (depending on source language and exactly which definitions you use) potentially also a transpiler.
Eh, I don't really see what this term gives us... So C2Rust is a compiler too, since Rust is compiled to LLVM?
There are all transglosser anyway. :P