PHP to become ahead of time compiled language?

1k views Asked by At

I explored the PHP history and the name Personal Home Page. In a brief what I found:

Dealing with gcc, make or ld for Web developers was not fun. To create web pages (Personal Home Pages) they found recompiling each time is complex.

This is why PHP we write will be interpreted (even HHVM where we have intermediate bytecode).

Do you see any technical problem, and is it smart to make PHP ahead of time compiled? Are there any plans?

PS. My wish would be for PHP to be ahead of time (pre-compiled), not JIT.


UPDATE:

As I found out project php-compiler supports "ahead of time" compiler option.

Compile - Ahead Of Time Compilation

This compiler mode actually generates native machine code, and outputs it to an executable. This means, that you can take PHP code, and generate a standalone binary. One that's implemented without a VM. That means it's (in theory at least) as fast as native C. Well, that's not true. But it's pretty dang fast.

1

There are 1 answers

0
BareNakedCoder On BEST ANSWER

When Python code is first invoked, it (usually) is parsed/interpreted once into byte code and saved in a .pyc file and then executed. The next time the code is invoked, the ahead-of-time interpreted byte code is found in the .pyc file and that is executed.

For PHP, since PHP 5.5, an opcode cache has been included. When PHP code is first invoked, it (usually) is parsed/interpreted once into byte code and saved in the opcode cache and then exectued. The next time the code is invoked, the ahead-of-time interpreted byte code is found in the opcode cache and that is executed.

Byte code is close enough in performance to native code. There is not much motiviation for compiling ahead of time to native for eitther Python or PHP. You would give up the fast edit-save-reload-browser development cycle for unneeded gains in performance.