6 ms·
Is there a more appropriate word for source-to-source transformation? I understand that compilers aren't that different, but generating machine code is quite di
by mvdan 8y ago
Is there a more appropriate word for source-to-source transformation? I understand that compilers aren't that different, but generating machine code is quite different.
- fiddlerwoaroof 8y agoMachine code is just source code for a cpu. Anyways, how is a transpiler different from a bytecode compiler, except that the bytecode is human readable?
- tlrobinson 8y ago> how is a transpiler different from a bytecode compiler, except that the bytecode is human readable? The bytecode is human readable.
- monocasa 8y agoThe assembly that comes out of GCC is human readable too (the actual assembling occurs via a different program from a different project than GCC). Is GCC a transpiler?
- tlrobinson 8y agoNo, because assembly is not approximately the same level of abstraction as C.
- monocasa 8y agoHow do you define that in a way that isn't a tautology?
- tlrobinson 8y ago"I'll know it when I see it" I'm not going to waste any more time defining things for you. Suffice to say, Go and JavaScript are roughly the same level of abstraction.
- monocasa 8y agoYou haven't really defined anything though. Your joke is kind of to my point.
- tlrobinson 8y agoNot sure if trolling. I think most programmers have a sense of what constitutes "roughly the same level of abstraction". Certainly there are gray areas, but such is life.
- monocasa 8y agoI've been mainly asking, how does the compiler intrinsically change depending on the abstraction of it's source and target? In my mind your argument is equivalent to to separating novels based on if they were written with a pen or a pencil. Yes, there's a difference between a pen and a pencil, but that has no effective bearing on the novel as written. And it doesn't make sense to categorize novels based on that.
- Stratoscope 8y agoBack around 1985, I got involved in a discussion on BIX with Bjarne Stroustrup about whether Cfront was a compiler or not. Cfront was Bjarne's original C++ compiler. It translated C++ code into C code which would then be passed through a C compiler. I didn't think Cfront should be called a compiler, because it didn't compile down to machine code and not even to assembly, only to another relatively high level language. Bjarne was quite insistent that Cfront really was a compiler, and the fact that it compiled to another source language was immaterial. It did essentially the same things as any compiler, it only had a different back end code generator. And the code generator could later be swapped out for one that generates machine code. Of course you can call it whatever you want, but Bjarne called it a compiler.
- monocasa 8y ago> but generating machine code is quite different It really isn't though. PCC just walked the AST, writing out text to a file with hardly any optimizations just like most of what people call 'transpilers'. But you wouldn't call a c compiler to asm a transpiler, right? Pretty much everything that gets attributed to some intrinsic difference between source-source and source-machine compilers is just a function of the immature tooling on the web.
- sigjuice 8y agoAlso, source-to-source compiler can be shortened to compiler. The phrase source-to-source is redundant.
- sakuronto 8y agowhat about high-level-language-to-high-level-language compiler?
- monocasa 8y agoNope. There's the (albeit not 100% correct) meme that C is portable PDP-11 asm. What is correct in my mind is that PCC has much fewer, much less complicated transformations to go to PDP-11 (or M68k) asm than Babel does to go from ES-next to ES5. But for some reason Babel is a transpiler because it's all high level and that's magically different. And no one in their right mind would attempt to call the c compiler of the 1980s a transpiler.
- svnsets 8y agoThe only difference between the two in my mind is that the output from a transpiler is likely going to have a ton of bloat, require additional transforming, and be a much larger amount of code than the sum of the inputs. Whereas something like the Closure Compiler actually optimizes and eliminates dead code. They are the same thing though from an ideological standpoint though.