I see how to write compilers in JavaScript (because the network puts it on us), but it sounds like a waste of time.
haXe is already doing this, although it is not specifically aimed at PHP (related to the Wikipedia article, not to their site, I am afraid that I will be operated if I am on this site ...)
PHP is easy to deploy anywhere
... like its vulnerabilities.
I know this sometimes allows a very bad design.
This is a bit of an understatement, it doesn't even have a modular system, there is no encapsulation, and it has a lot of dumb things, such as dynamic name resolution .
PHP is pretty slow as it is, do you really want something an order of magnitude smaller?
Java is much easier to deploy anyway and allows you to go to the bytecode level if you want. Java also gives you access to moderately reasonable libraries.
L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳ Jan 25 2018-11-11T00: 00Z
source share