|
|
|
|
|
by sradman
2094 days ago
|
|
Truffle is an integration layer for interpreted languages in GraalVM. The canonical Truffle language included in the Graal distribution is GraalJS, a replacement for the now deprecated Nashorn JavaScript engine for the JVM. Similarly, TruffleRuby is an alternative to JRuby and GraalPython is an alternative to Jython. Neither of these Truffle implementations has gained traction and they will not until they fully implement the main frameworks for each ecosystem (Ruby on Rails and Django/NumPy respectively). The same will hold true for a Truffle implementation of PHP. It will need to support the C interface components like PDO database drivers and the Laravel web framework. The linked project was created as part of a graduate thesis and demonstrates the feasibility of GraalVM/Truffle as a performant polyglot platform. I'm not convinced that Ruby/Python/PHP integration with Java Bytecode is an important use case moving forward. It could have been when Rails/Django/Laravel were on top of the web framework game but the demand for this use case is diminishing. |
|
When you have a JIT based language you want as much to be executed in that language, jumping back and forth between PHP and C is a drawback from a JIT perspective.
However there exist many PHP C extensions that are just thin wrappers around large C libraries like cURL, it is not really feasible to implement that in pure PHP.
But with the introduction of a foreign function interface with PHP 7.4 that has made it possible to call C libraries with ease, as long the C library doesn't do too much macro magic, and to my understanding upcoming Java release ships with a much improved native bridge with better support for native types, these two thing could lead to, guessing here, that you only need to implement the bridge for each implementation but share the rest of the PHP wrapper code for that C library.
However the foreign function interface introduced in PHP 7.4 is signigfanctly slower that the old style C extension of Zend PHP, but to my understanding is that future evolution of the JIT could theoretically reduce that performance impact.