It is called a compiler even it outputs code in another language, transpiler is some neologism from JavaScript developers without a background in compiler design.
I'd defend the word 'transpiler' and I did my masters and PhD on language implementation, and that's where I work professionally now, so I'm not ignorant of compilers.
I think it implies a translation from one high level language to another (not that 'high level' is well defined either), with only desugaring and maybe type-checking - no real lowering or optimisations. That's a useful subset of compilers, so can have its own word I believe.
Why are people giving this word so much flak? Yes it's a neologism, but it's a useful one. A decompiler is a compiler to, it just goes from a low level language to a high level one. Do you suggest that we stop using the word decompiler as well?
> It is called a compiler even it outputs code in another language
Indeed and most compilers do exactly that. Cant help getting a little annoyed whenever I hear this 'transpiler' word. I guess the ship has sailed, oh well !
From what I've noticed, these "transpilers" output code that is readable (the code itself is written as though a human wrote it) where as "compilers" output code that has been optimized and show effects of name mangling in the code itself, etc. Just an observation.
I think it makes sense to use a different term for this "compiler"-esque behavior. For example, I might edit the output of CoffeeScript generated Javascript whereas I wouldn't know how to modify the output of gcc.
People believe some languages are "higher level" than others and call a tool that translates programs written in A to programs written in B a compiler if A is clearly higher level than B and a transpiler if B is of a level higher than or roughly equal to A.
You can certainly think this distinction doesn't merit using a different word, but you shouldn't think that people who use the word "transpile" use it as a synonym for "compiler".
This seems to me to be very close to what Pythran [0] is doing (since 2011), except that Pythran includes some type inference and bridge with Python code.
So view through that lens I'm not really seeing the novelty right now?
Should be noted that this only works on a "statically typeable" subset of Python where every variable has a de facto static type inferred at the first assignment. For instance, the following valid Python code would output invalid C++:
... and unpython, spyke .... all very cool and with their own spin. What is a little worrisome is the rate at which these get abandoned and how many of them target some specific subset of Python. I particularly liked unpython's take.
Would someone be kind to explain how the transpiler/compiler knows that
num of T1 generic(?) type can be used with the <= operator?
Or that something the user themselves have to define?
Wouldn't be something like "T1 where T1 is Numeric"?
This is how C++ templates work. They are a form of polymorphism through how you use the object and not based on its type.
If you pass a type that cannot be used with the <= operator it will error in compile time.
Being able to do this is part of why C++ templates are much more powerful than Java/C# generics and why they enable a different (and alternative) form of polymorphism to inheritance and explicit interfaces.
Writing something like this for Python 2 is like throwing a urine filled water balloons at all the progressive developers working hard to get the Python community transitioned to Python 3.
Don't have enough reasons to stick with shitty old Python 2, well then here's another anchor for your boat!
Edit: The first pull request was for Python 3 support, hooray.
pjmlp|10 years ago
chrisseaton|10 years ago
I think it implies a translation from one high level language to another (not that 'high level' is well defined either), with only desugaring and maybe type-checking - no real lowering or optimisations. That's a useful subset of compilers, so can have its own word I believe.
poizan42|10 years ago
kitd|10 years ago
It's just short-hand for source-to-source compiler and IMHO has been used enough to warrant its inclusion in a programmer's dictionary.
srean|10 years ago
Indeed and most compilers do exactly that. Cant help getting a little annoyed whenever I hear this 'transpiler' word. I guess the ship has sailed, oh well !
nimitkalra|10 years ago
I think it makes sense to use a different term for this "compiler"-esque behavior. For example, I might edit the output of CoffeeScript generated Javascript whereas I wouldn't know how to modify the output of gcc.
omaranto|10 years ago
You can certainly think this distinction doesn't merit using a different word, but you shouldn't think that people who use the word "transpile" use it as a synonym for "compiler".
lmm|10 years ago
morgenkaffee|10 years ago
But it fits the project since I don't have any background or experience in compiler design.
tormeh|10 years ago
jmgao|10 years ago
drvortex|10 years ago
But a compiler has come to mean a program that translates source-code into machine code.
By this new understanding, a transpiler is a combination of a compiler and a decompiler with different input and output languages.
So po-tay-toes, po-taa-toes. No one cares, we know what is meant by transpiler.
programmer_man|10 years ago
Point taken that it is still a compiler.
agumonkey|10 years ago
throwaway999888|10 years ago
haberman|10 years ago
Viewed through that lens, this is a really novel and cool demonstration.
Joky|10 years ago
So view through that lens I'm not really seeing the novelty right now?
[0]: http://github.com/serge-sans-paille/pythran/
Sharlin|10 years ago
morgenkaffee|10 years ago
For the array I do a little hackery. You can define the array without an initial value in the container and I can guess the value type.
it will spit outexprx|10 years ago
Fede_V|10 years ago
srean|10 years ago
seivan|10 years ago
Wouldn't be something like "T1 where T1 is Numeric"?
Thanks!
inglor|10 years ago
If you pass a type that cannot be used with the <= operator it will error in compile time.
Being able to do this is part of why C++ templates are much more powerful than Java/C# generics and why they enable a different (and alternative) form of polymorphism to inheritance and explicit interfaces.
morgenkaffee|10 years ago
techdragon|10 years ago
Don't have enough reasons to stick with shitty old Python 2, well then here's another anchor for your boat!
Edit: The first pull request was for Python 3 support, hooray.
anc84|10 years ago