Live data from Hacker News

Show HN: Python to C++14 transpiler

github.com

31–40 of 47 posts

Re: Show HN: Python to C++14 transpiler

#31
post #13

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++: var = [] var = 2

Well, you could always begin another scope with each assignment.

    auto var = // this type can't be inferred because it's not used
    {
      auto var = 2;
    }
I'm too exhausted to think why this may not be applicable.

Re: Show HN: Python to C++14 transpiler

#32
post #29
post #27

Earlier quoted context omitted.

'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.

Yes they have, and we called them compilers. Can you dig me a 70's paper with the transpiler word on it?

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

#33
post #29

Earlier quoted context omitted.

Yes they have, and we called them compilers. Can you dig me a 70's paper with the transpiler word on it?

There's this paper from 1964, shortly before the last paragraph. http://comjnl.oxfordjournals.org/content/7/1/28.full.pdf+htm...

Wow, what a refutation! Hope this puts an end to focusing on a word, rather than the work itself. Nice paper btw.

Re: Show HN: Python to C++14 transpiler

#34
post #28

Earlier quoted context omitted.

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…

So for you a C compiler that follows the initial workflow is a transpiler? Or an Eiffel implementation, as another example.

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

#35
post #6

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.

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

#36
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.

Re: Show HN: Python to C++14 transpiler

#37
post #29

Earlier quoted context omitted.

Yes they have, and we called them compilers. Can you dig me a 70's paper with the transpiler word on it?

There's this paper from 1964, shortly before the last paragraph. http://comjnl.oxfordjournals.org/content/7/1/28.full.pdf+htm...

Thanks, it seems I need to fix my stance on it.

Re: Show HN: Python to C++14 transpiler

#38
post #28

Earlier quoted context omitted.

So for you a C compiler that follows the initial workflow is a transpiler? Or an Eiffel implementation, as another example.

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 kn…

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

#39
post #3
post #2

Key sentence: "The goal is to showcase the power of C++14 templates and not to create a fully functional transpiler." Viewed through that lens, this is a really novel and cool demonstration.

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? [0]: http://github.com/serge-sans-paille/pythran/

There is also nuitka - http://nuitka.net/

Re: Show HN: Python to C++14 transpiler

#40

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.

No need to phrase it so nastily.
Post reply on HN