3 ms·
At that point, I ask myself whether it's possible to interface strongly-typed PHP with Java. Like, either a PHP frontend for JVMs (just like Kotlin and whatnot)
by mschuster91 3y ago
At that point, I ask myself whether it's possible to interface strongly-typed PHP with Java. Like, either a PHP frontend for JVMs (just like Kotlin and whatnot), or run Java code inside PHP in a run-and-throw-away model.
Almost everything but async/threads that I use in Java stuff has an 1:1 mapping.
- janosdebugs 3y agoSeveral years ago I worked on an interop project with Quercus, not sure if that project is still alive and tracking the changes.
- djxfade 3y agoNot sure about Java, but PHP does support FFI and can interface with C applications.
- blowski 3y agoIn theory, it sounds pretty interesting. PHP's ethos is quite different though - e.g. PHP's "arrays for everything" vs Java's "specific types for every case". Also, the absence of generics in PHP is a huge difference.
- mschuster91 3y agoAt least the PHP-in-JVM side shouldn't be that complex to do then... a LinkedList<Object> should be enough to match PHP arrays functionally. The largest challenge in a PHP-in-JVM project probably would be re-implementing its large stdlib as a wrapper around native Java.
- actionfromafar 3y agoOr, don't: as in compile PHP library to JVM. Something like https://github.com/mridoni/llxvm https://github.com/mridoni/llxvm
- DarkNova6 3y ago> PHP's "arrays for everything" I think that's more a framework/library philosophy than anything else. When I dabbled with PHP + symfony, I worked with some of the most clean APIs I've seen to this date.
- berkes 3y agoPHP core has very few datatypes. And many are really just Arrays. Not just "under the hood" but through public interfaces. The best example to show this is that you can `foreach()` over an object. It wasn't a deliberate feature but rather an artifact of how objects are "syntactic sugar over Arrays" and how Arrays are really just hashtables. And it becomes problematic with the many exceptions that all the functions operating on Arrays have. Almost all important functions' documentation (edit: on arrays) goes something like "if the array key is a string, it will act like X, if it is a number it will act like Y". With some going like "if one of the keys is a string it will X, otherwise it will Y". And Y and X being rather different in return values, errors and such. I can understand that PHP has a really strong preference for strings - HTTP is only and all strings after all - but the mess around arrays is real, dangerous, and has bitten me, my companies and many of my clients many times over. For decades.
- salzig 3y agoyou mean like https://www.caucho.com/resin-3.1/doc/quercus.xtp https://www.caucho.com/resin-3.1/doc/quercus.xtp?
- mschuster91 3y agoYup, but looks like that hasn't seen any updates since 2014 [1]. [1] http://quercus.caucho.com/ http://quercus.caucho.com/
- salzig 3y agoI've worked at a php3+php4+php5 (three generation of source code, in a single repository) + Java Application in the past. I'll never miss that time :)
- tored 3y agoI should be, it already exist a .NET implementation of PHP. https://www.peachpie.io/ https://www.peachpie.io/ https://www.peachpie.io/usecases https://www.peachpie.io/usecases