Live data from Hacker News

Deep Dive into PHP 8's JIT

thephp.website

11–20 of 66 posts

Re: Deep Dive into PHP 8's JIT

#11

Earlier quoted context omitted.

The statement would be far more accurate as "language X is [almost always/sometimes/often/commonly/etc.] interpreted/compiled". Unfortunately a lot of people seem to like speaking in absolutes. C can be interpreted too: https://en.wikipedia.org/wiki/CINT

Theoretically, any language can be interpreted. Compilation is just interpreting what a program does and producing machine code (or other code in the case of transpilers) that computes the same thing. Interpreters are just that, but instead of producing code, they run code in themselves thats computes the results directly. One could even consider machine code just “obfuscated” assembly code. In that sense, machine co…

[deleted]

Re: Deep Dive into PHP 8's JIT

#13

Earlier quoted context omitted.

The statement would be far more accurate as "language X is [almost always/sometimes/often/commonly/etc.] interpreted/compiled". Unfortunately a lot of people seem to like speaking in absolutes. C can be interpreted too: https://en.wikipedia.org/wiki/CINT

Theoretically, any language can be interpreted. Compilation is just interpreting what a program does and producing machine code (or other code in the case of transpilers) that computes the same thing. Interpreters are just that, but instead of producing code, they run code in themselves thats computes the results directly. One could even consider machine code just “obfuscated” assembly code. In that sense, machine co…

"question: is there a language that can’t be compiled?"

There is some question whether Perl could be, because parsing it without running it has some ambiguity. https://www.perlmonks.org/?node_id=663393

Re: Deep Dive into PHP 8's JIT

#14

"PHP as fast as C" - People who are in php language development may die laughing reading this statement. Truth can be harsh, but people sometime overvalue to such an extent is hard to understand.

What I've noticed is that JITs often can reach C speed in workloads like this:

    sum = 0
    for i in xrange(n):
      for j in xrange(i):
        sum += A[i][j]
And when they reach that milestone, some people call it "as fast as C".

Never mind that that's not what people actually write in Python or PHP. It's a synthetic benchmark, not a real workload.

The workloads in those languages are generally oriented around strings, hash tables, and function/method calls.

And the JITs don't seem to do nearly as good a job there. I tested PyPy on Oil [1] a few years ago, and it made it slower, not faster. And it used more memory. (Though PyPy is an amazing project in many respects.)

[1] https://www.oilshell.org

Re: Deep Dive into PHP 8's JIT

#15
post #13

Earlier quoted context omitted.

Theoretically, any language can be interpreted. Compilation is just interpreting what a program does and producing machine code (or other code in the case of transpilers) that computes the same thing. Interpreters are just that, but instead of producing code, they run code in themselves thats computes the results directly. One could even consider machine code just “obfuscated” assembly code. In that sense, machine co…

"question: is there a language that can’t be compiled?" There is some question whether Perl could be, because parsing it without running it has some ambiguity. https://www.perlmonks.org/?node_id=663393

By wielding the Futamura projections [0][1][2], any interpreter may be turned into a compiler. Perl is handled as one case. Crucially, the resulting compiler need not be fast; if the interpreter is slow, then the compiler will be slow too (this is a special case of the central meme from [3], "if the N'th Futamura projection has quality Q, then the N+1'th Futamura projection will also have quality Q.")

[0] https://en.wikipedia.org/wiki/Partial_evaluation#Futamura_pr...

[1] http://blog.sigfpe.com/2009/05/three-projections-of-doctor-f...

[2] https://www.gwern.net/docs/cs/2009-gluck.pdf

[3] https://www.itu.dk/people/sestoft/pebook/

Re: Deep Dive into PHP 8's JIT

#16

Earlier quoted context omitted.

The statement would be far more accurate as "language X is [almost always/sometimes/often/commonly/etc.] interpreted/compiled". Unfortunately a lot of people seem to like speaking in absolutes. C can be interpreted too: https://en.wikipedia.org/wiki/CINT

Theoretically, any language can be interpreted. Compilation is just interpreting what a program does and producing machine code (or other code in the case of transpilers) that computes the same thing. Interpreters are just that, but instead of producing code, they run code in themselves thats computes the results directly. One could even consider machine code just “obfuscated” assembly code. In that sense, machine co…

> This brings up a slightly related question: is there a language that can’t be compiled?

Not sure if you're asking this platonically, but Futamura shows us that if you can built an interpreter then you can always transform that automatically to be a compiler.

This is used in practice by some compilers today - they automatically produce a compiler from an interpreter!

Re: Deep Dive into PHP 8's JIT

#18
post #14

"PHP as fast as C" - People who are in php language development may die laughing reading this statement. Truth can be harsh, but people sometime overvalue to such an extent is hard to understand.

What I've noticed is that JITs often can reach C speed in workloads like this: sum = 0 for i in xrange(n): for j in xrange(i): sum += A[i][j] And when they reach that milestone, some people call it "as fast as C". Never mind that that's not what people actually write in Python or PHP. It's a synthetic benchmark, not a real workload. The workloads in those languages are generally oriented around strings, hash tables,…

This is not what people write in Python or PHP, but this is what people write in C extensions for Python or PHP. Having your JIT be that fast allows you to forego those extensions and write the low-level hot loops in the same language, and that's a huge improvement.

You usually don't care how your matrix multiplication/regex matching/unicode normalization/JSON parsing is implemented, but people had to make those, and they are users of the language too.

Even though it might not change the bottom-line for your high-level app.

Re: Deep Dive into PHP 8's JIT

#19

Earlier quoted context omitted.

The statement would be far more accurate as "language X is [almost always/sometimes/often/commonly/etc.] interpreted/compiled". Unfortunately a lot of people seem to like speaking in absolutes. C can be interpreted too: https://en.wikipedia.org/wiki/CINT

Theoretically, any language can be interpreted. Compilation is just interpreting what a program does and producing machine code (or other code in the case of transpilers) that computes the same thing. Interpreters are just that, but instead of producing code, they run code in themselves thats computes the results directly. One could even consider machine code just “obfuscated” assembly code. In that sense, machine co…

Of course not, just compile your interpreter but instead of reading input from a file, have it read input from a fixed string (the source code) that is embedded in the binary. You've just created a super shitty compiler!

Re: Deep Dive into PHP 8's JIT

#20
post #14

"PHP as fast as C" - People who are in php language development may die laughing reading this statement. Truth can be harsh, but people sometime overvalue to such an extent is hard to understand.

What I've noticed is that JITs often can reach C speed in workloads like this: sum = 0 for i in xrange(n): for j in xrange(i): sum += A[i][j] And when they reach that milestone, some people call it "as fast as C". Never mind that that's not what people actually write in Python or PHP. It's a synthetic benchmark, not a real workload. The workloads in those languages are generally oriented around strings, hash tables,…

What I want to see a benchmark like this one, https://kinsta.com/blog/php-benchmarks/

I think a workload like this is more common in the PHP world. Not saying that others don’t exist, but handling routing, queries, cached content is very different from simply doing mathematical/memory intensive applications.

Post reply on HN