News for hackers. Stuff that matters.
Re:Show HN: Python to C++14 transpiler by pjmlp on Monday January 18, 2016 @02:35AM (#10923097)
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.
Re:Show HN: Python to C++14 transpiler by chrisseaton on Monday January 18, 2016 @04:19AM (#10923409)
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.

Re:Show HN: Python to C++14 transpiler by pjmlp on Monday January 18, 2016 @07:24AM (#10923967)
So for you a C compiler that follows the initial workflow is a transpiler?

Or an Eiffel implementation, as another example.

Re:Show HN: Python to C++14 transpiler by chrisseaton on Monday January 18, 2016 @08:37AM (#10924275)
I think a transpiler is a compiler that does a high-level to high-level translation with only a few simple transformations and almost no optimisations and produces relatively readable output.

If a C or Eiffel compiler meets that definition then yes. I'd still call it a compiler, but I would also call it a transpiler.

If you're offended by the term transpiler because all transpilers are also compilers, then I don't know why you wouldn't also be offended by the term compiler because all compilers are also 'programs', so lets just call everything a 'program'.

Re:Show HN: Python to C++14 transpiler by pjmlp on Monday January 18, 2016 @09:46AM (#10924635)
Apparently I am the one wrong here, given the 1964 paper link provided by Ded7xSEoPKYNsDd.

Still the word sounds strange.

Re:Show HN: Python to C++14 transpiler by poizan42 on Monday January 18, 2016 @05:53AM (#10923673)
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?
Re:Show HN: Python to C++14 transpiler by kitd on Monday January 18, 2016 @06:39AM (#10923822)
'Transpiler' goes back long before the Javascript/CoffeScript world. Pascal/C and FORTRAN/C have a history of 'transpilation' products.

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.

Re:Show HN: Python to C++14 transpiler by pjmlp on Monday January 18, 2016 @07:28AM (#10923981)
Yes they have, and we called them compilers.

Can you dig me a 70's paper with the transpiler word on it?

Re:Show HN: Python to C++14 transpiler by Ded7xSEoPKYNsDd on Monday January 18, 2016 @08:02AM (#10924117)
There's this paper from 1964, shortly before the last paragraph.

http://comjnl.oxfordjournals.org/content/7/1/28.full.pdf+htm...

Re:Show HN: Python to C++14 transpiler by pjmlp on Monday January 18, 2016 @09:44AM (#10924625)
Thanks, it seems I need to fix my stance on it.
Re:Show HN: Python to C++14 transpiler by srean on Monday January 18, 2016 @02:51AM (#10923136)
> 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 !

Re:Show HN: Python to C++14 transpiler by nimitkalra on Monday January 18, 2016 @03:21AM (#10923226)
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.

Re:Show HN: Python to C++14 transpiler by pjmlp on Monday January 18, 2016 @03:30AM (#10923254)
The output of gcc can be straight readable Assembly, once upon a time a normal language to write business applications in.

Also C compilers used to generate Assembly text files, which were then piped into the Assembler.

So no, transpiler doesn't make any sense.

Re:Show HN: Python to C++14 transpiler by kqr on Monday January 18, 2016 @05:47AM (#10923644)
This is even better highlighted by something like the GHC compiler, which compiles Haskell to (ultimately) machine code, because it does this in several steps:

1. As a first step, it "transpiles" Haskell to the very similar high-level intermediate language called Core. I could read and write programs in Core without too much effort because it's still a very high-level language.

2. Then it "transpiles" the Core code to the not significantly lower level STG source code – human readable, but starts dealing in a little lower-level stuff and contains much fewer bells and whistles. I'd prefer not to work in STG, but I totally could if I had to.

3. After this, it again "transpiles" the STG source code to the C-- (C-minus-minus) intermediate language, which is decidedly low-level (slightly lower level than regular C code), but there's still a clear and relatively simple translation between STG and C--.

4. As a final step, it "transpiles" the C-- source code to assembly (a closer match than you may think, coming from C), which can be assembled into machine code.

At no point in this pipeline is there a significant magic translation being made – despite the fact that Haskell is probably one of the most high-level languages we know and machine code is as low-level as you get.

Re:Show HN: Python to C++14 transpiler by omaranto on Monday January 18, 2016 @03:54AM (#10923335)
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".

Re:Show HN: Python to C++14 transpiler by lmm on Monday January 18, 2016 @05:47AM (#10923645)
The distinction is meaningful and valuable. Language evolves. No need for the attacks.
Re:Show HN: Python to C++14 transpiler by morgenkaffee on Monday January 18, 2016 @02:56AM (#10923156)
You are right. C++ is quite different to Python and so it should be called a compiler.

But it fits the project since I don't have any background or experience in compiler design.

Re:Show HN: Python to C++14 transpiler by tormeh on Monday January 18, 2016 @04:40AM (#10923487)
Transpilers are a subcategory of compilers. It's just a more specific word.
Re:Show HN: Python to C++14 transpiler by jmgao on Monday January 18, 2016 @03:10AM (#10923195)
Alternatively, translator, the word that CFront used.
Re:Show HN: Python to C++14 transpiler by Sharlin on Monday January 18, 2016 @03:35AM (#10923274)
And "translation" is still the term of art for the compilation process at least in the C and C++ standards.
Re:Show HN: Python to C++14 transpiler by drvortex on Monday January 18, 2016 @09:12AM (#10924446)
Strictly you are right. However, by the strict definition of a compiler, an interpreter is nothing but a sort-of "real time compiler".

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.

Re:Show HN: Python to C++14 transpiler by programmer_man on Monday January 18, 2016 @10:52AM (#10925035)
The word transpiler was used before we had web browsers, much less javascript.

Point taken that it is still a compiler.

Re:Show HN: Python to C++14 transpiler by agumonkey on Monday January 18, 2016 @04:31AM (#10923450)
or pretty printing
Re:Show HN: Python to C++14 transpiler by throwaway999888 on Monday January 18, 2016 @06:11AM (#10923733)
I for one am just waiting for the cispiler.
Re:Show HN: Python to C++14 transpiler by Symmetry on Monday January 18, 2016 @11:15AM (#10925180)
An optimizing cispiler sounds really interesting. Something that applies all the optimizations that the compiler would do when translating your C to machine code but showing you the results in C. Of course not all optimizations are representable in C (calling conventions for instance) but many are.
Re:Show HN: Python to C++14 transpiler by jmgao on Monday January 18, 2016 @04:53PM (#10927273)
There are several examples of this in the Java world, such as proguard. They're mostly centered around code obfuscation, but they do some useful optimizations as well.