PHP to Java bytecode

From this post on the server side it seems Caucho have added PHP support to their Resin Java App server.

There are a number ways to integrate with Java, by which I mean PHP – the C version.

What’s interesting about what Caucho seem to have done is, rather than integrate with PHP-C, they’ve written their own parser for PHP scripts in Java, from which they generate Java byte code for execution. I say “seem” because I’ve only glanced at the source and found a convincing-looking PHP parser in there.

Otherwise not much information available right now except the source code itself and some minimal wiki entries.

Also, Keith raises the right questions about benchmarks.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • mlemos

    PHP is a glue language. It means that most of the time it is calling external libraries hand-written in C. So, when somebody compares the speed of PHP with Java or anything else, they should be comparing with the speed of the external libraries because most of time of executing CPU intensive tasks is spent on such libraries.

    For instance, if you want to use cryptography algorithms, you use mcrypt/mhash functions. If you want to use regular expressions, you use preg functions, etc..

    Furthemore, great part of the time that a PHP scripts take to execute is on waiting: waiting for receiving data from the Web browser or Web server, waiting for sending or receiving data from a database server, etc..

    Therefore, making claims that PHP compiled to Java is 6 times faster, is wishful thinking. They should try real world scripts instead of HelloWorld snippets before making any serious performance claims.

    It seems that for some Java fans, admiting that PHP can be as good or better than Java is a great humilliation. Pride and arrogance are not uncommon in the Java world.

    However, a good professional should stay away from passions that blind people, so they choose a language more appropriate according to their current needs. Sometimes PHP is better, other times Java or something else is more convinient. I am sure that most of the times performance is not the issue that makes developers with a clue decide.

    On a related subject, AFAIK Roadsend can not only compile PHP code into native code, but also perform JIT. This means that you can mix compiled code with PHP source code. The PHP source code is compiled Just-In-Time before executing. So, JIT compilers are not a privilege of the Java world.

    There is also the PHPCompiler project that is Open Source and seems to promise similar goals to RoadSend.

  • bonefry

    > Therefore, making claims that PHP compiled to Java is 6 times faster, is
    > wishful thinking. They should try real world scripts instead of HelloWorld
    > snippets before making any serious performance claims.

    LOL

    > It seems that for some Java fans, admiting that PHP can be as good or better
    > than Java is a great humilliation. Pride and arrogance are not uncommon in the
    > Java world.

    Caucho has added PHP support to their Resin server to broaden their offerings.
    PHP can act as a glue language for Java now instead of C.

    But I see your arrogance blinds you. And yet I won’t say that *all* PHP fans are blinded by arrogance, just because you are ;)

  • mlemos

    If you read again, maybe you notice I said some Java fans. However, it seems did not see that. What do you call somebody that does not see? Never mind. Maybe I just need glasses! ;-)

  • Anonymous

    dfffdrfdddddddddddd

  • Dennis

    This project is great for Caucho users, but completely useless for the larger Java and PHP communities.