Home  >  Article  >  Backend Development  >  Compiler that compiles PHP source code into JVM bytecode: JPHP

Compiler that compiles PHP source code into JVM bytecode: JPHP

WBOY
WBOYOriginal
2016-07-25 09:12:391575browse

JPHP is a compiler similar to javac, which can compile PHP source code into JVM bytecode. Then it was realized to let the PHP program run on the Java virtual machine. It supports many PHP5.3+ features. JPHP is similar to JRuby and Jython.

Support: JDK 1.6+ (OpenJDK, Oracle).

Goal

JPHP is not a replacement for the Zend PHP engine or Facebook HHVM. It does not want to implement the zend runtime library (such as Curl, PRCE, etc.). This item is for:

  1. Ability to use useful Java objects in PHP
  2. Improving performance through JIT and JVM
  3. Utilize a better runtime library instead of Zend PHP’s ugly runtime library
  4. Let PHP not only be used to develop web applications
  5. Also: unicode for strings and threads

Features

  • JIT (2x - 10x faster PHP 5.4)
  • Optimizer (constant expressions, inline functions, etc.)
  • Using java libraries and classes in PHP code.
  • Unicode for strings (UTF-16, like in Java)
  • Threading, Sockets
  • Environment architecture (like sandbox objects in runkit zend extension).
  • GUI (based on Swing, improved - more flexible layouts)
  • Embedded cache system for classes and functions
  • Optional Hot Reloading for classes and functions

Language supported features

(without zend runtime libraries)

  • PHP 5.2+ fully supported (with OOP)
  • Closures (PHP 5.3), auto-binding $this in closures (PHP 5.4)
  • Namespaces fully supported (PHP 5.3)
  • Spl autoloading for classes (PHP 5.3)
  • Iterators, ArrayAccess, Serializable
  • Type hinting for classes, arrays, callable (PHP 5.4)
  • Array short syntax (PHP 5.4)
  • Ternary short cut "?:", NOWDOC, __callStatic, __invoke (PHP 5.3)
  • Late static binding (PHP 5.3)
  • GC for cyclic references (PHP 5.3)
  • Class::{expr}(), (new Foo)->bar() (PHP 5.4)
  • Try finally (PHP 5.5)
  • Array and string literal dereferencing (PHP 5.5)
  • __debugInfo for var_dump (PHP 5.6)
  • Function array dereferencing has been added, e.g. foo()[0] (PHP 5.4)
  • Constants can be declared outside a class using the const keyword. (PHP 5.3)
  • Dynamic access to static methods (PHP 5.3)
  • Exceptions can be nested (PHP 5.3)
  • ::class system constant (php 5.5)

What doesn’t it support yet?

  • Traits (php 5.4)
  • Generators (php 5.5)
  • Goto (php 5.3)
  • list() in foreach (php 5.5)
  • Binary number format, e.g. 0b001001101 (php 5.4)

Project homepage: http://www.open-open.com/lib/view/home/1395628572618



    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn