Hacker News new | past | comments | ask | show | jobs | submit login

>No, it doesn't. You could easily compile Python into C (basically, "just" inline the core interpreter loop), but it will still be slow, because the Python semantics still require a lot of dictionary resolutions on every operation.

Yeah, and you could do this too at the start of your emitted code from the transpiler:

sleep(UINT_MAX)

which would also make it slower than an interpreted language. But I specified I wasn't talking about that, or about "just inlining the core interpreter loop", but about transpiling letting you also emit straightforward and clean code without extra abstractions for most operations.

A new language like Nim doesn't come with all the baggage of Python's runtime pre-existing, and doesn't need to recreate it.




HipHop doesn't support the entirety of the PHP runtime for exactly the reasons that have been laid out for you.

That's reality from a company with a shitton of money and a vested interest in doing it successfully.

They can't do it in the general case because reality disagrees with you.


Not sure what are you getting at. What I didn't say: transpiling is magic fairy dust for speed, and you don't have to care about language semantics at all.

What I said: "unless done badly" (my words on the original comment), it's fast, as it gives you a chance to emit straightfoward C code for most operations. Now, regarding your example:

First, HipHop is not transpiled to C. It's a runtime with a JIT.

Second, what does "HipHop not supporting the entirety of the PHP runtime" has to do with anything?

I take it you mean that the fact they had to skip some parts of the runtime for increased speed, proves something related to what I wrote. But (besides the JIT thing) PHP is not greenfield like Nim. They have a runtime, and it has to work in a certain way. PHP wasn't designed with transpiling in mind, and HipHop had to follow it closely as a design goal. I never said runtime decisions you have to mimic to be 100% compatible can't slow you down.


http://en.wikipedia.org/wiki/HipHop_for_PHP

> HipHop for PHP (HPHPc) is a PHP transpiler created by Facebook. By using HPHPc as a source-to-source compiler, PHP code is translated into C++, compiled into a binary and run as an executable, as opposed to the PHP's usual execution path of PHP code being transformed into opcodes and interpreted.


OK, I had in mind the JITed HipHop VM that they tout now (later development it seems).

Still, how does the original version of HipHop as a transpiling compiler invalidate what I said?

I said (check my original comment): unless you do it badly, transpiling to C gets you to run faster, because it lets you translate most operations to straightforward and fast C code.

And that's exactly the logic they followed and what they achieved: they transpiled PHP to C, as opposed from running it with PHPs runtime interpreter, in order to make it faster, and it worked.

That they skipped some parts of PHP runtime behavior/semantics, which if they didn't it would slow things down, doesn't clash with what I said. In fact it's already covered in my comment: "it let's you translate MOST" (not all) operations to fast C code.


> transpiling to C gets you to run faster

You're changing the context.

> while being fast since it's compiled to C. - them

> being compiled to C doesn't imply fast :) - me

> Unless done badly, it does. - you

You've switched to "faster" because it's a more defensible position, but that isn't the idea that was originally being responded to. That's why jerf said the following, emphasis mine:

> No, it doesn't. You could easily compile Python into C (basically, "just" inline the core interpreter loop), __but it will still be slow__


You're really providing further evidence for my pet theory that anybody who seriously uses the word "transpiler" has no clue how compilers work, or what they can and can not do. (This is on the theory that anybody who does have that understanding also understands that "transpiler" is a etymological solution to a problem that didn't exist... the word "compiler" already covered the bases completely and totally... if you actually understand them.)




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: