Jphp is a PHP implementation for Java virtual machines that supports many features of PHP (5.3+). Jphp is responsible for compiling the PHP source code into the JVM bytecode so that it can run on the JVM, similar to the implementations of JRuby, Jython, and so on. It supports JDK version 1.6 and above. The project originated in last October. Jphp no intention to replace the Zend PHP engine or Facebook HHVM (HHVM's idea is to compile PHP into an intermediate byte code, and then compile the bytecode into x64 machine code by JIT). The designer does not intend to implement Zend runtime libraries (such as curl, prce, etc.) for jphp for the following reasons:
- Ability to use Java class libraries in PHP
- Improve performance with JIT and JVM
- Replace Zend PHP's ugly Runtime library with a better run-time library
- Extend the use of the PHP language beyond the Web
- JVM has better support for Unicode strings and threading
Jphp has the following functions:
- JIT (2-10 times faster than PHP 5.4)
- Optimizer (optimize constant expressions, inline functions, etc.)
- Java class libraries and classes can be used in PHP code
- Unicode string (similar to UTF-16 in Java)
- threads, sockets
- Environment architecture (similar to sandboxed objects in Runkit Zend extensions)
- Support GUI, implemented on swing and improved, provides more flexible layouts
- Class-and function-oriented embedded cache system
- Optional thermal update for classes and functions (Optional hot reloading) mechanism
Language features include:
- Full support for PHP 5.2+ (including OOP)
- Closures (PHP 5.3), automatic binding of $this in closures (PHP 5.4)
- Fully supported namespaces (PHP 5.3)
- Class SPL Auto-load (PHP 5.3)
- Iterators, Arrayaccess and Serializable
- Type constraints for classes, arrays, and callable (PHP 5.4)
- Array phrase method (PHP 5.4)
- GC for circular references (PHP 5.3)
More features to view the Readme file for this project. In addition, Jphp provides some features that PHP does not support, such as the ability to use exceptions in the __tostring method, type constraints on scalars, and so on. Jphp is not the first attempt to improve PHP performance, we wait and see. Interested readers can download and try it out.
From: http://www.infoq.com/cn/news/2014/03/jphp |