Let PHP run on the JVM--jphp

Source: Internet
Author: User
Tags hhvm php language

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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.