By Alexander, a Senior Java/PHP Developer on Murano Software’s team
Facebook, as you may already know, is working to open source their PHP to C++ translator, called HipHop. There is a lot of buzz about it, so I think a summary will be handy.
Main points:
- It's free and open source.
- HipHop is already used by Facebook, so it's tested with their huge code base.
- Process is: PHP → С++ → GCC → binary.
- HipHop is not JIT. You should translate and compile all code on every deployment.
- Binary can work as standalone server (using libevent). Also, it can work in command line.
- Standalone server uses one process and many threads.
- It's not based on Zend Engine. Instead, C++ code compatible with PHP 5.2 is used.
- Extensions are converted to thread-safe C++ (standard PHP extensions are being developed in C).
- Many extensions already have been converted. These are used by Facebook.
- If you want to use HipHop, prepare to convert additional extensions yourself.
- Some PHP magic methods are supported, but the performance is the same as in PHP.
No support for:
- Windows.
- PHP 5.3 (will be implemented later).
- eval().
- create_function().
- preg_replace with /e modifier.
- function_exists() before function declaration.
Dynamic PHP functionality supported:
- Dynamic function call including call_user_func().
- Dynamic methods and properties.
- Dynamic variables, extract().
- Dynamic include().
- Redefinition of functions, classes and constants.
- __toString(), __get(), __set(), __call().
Thoughts:
Facebook made a great tool to make their codebase run faster without rewriting it in C or C++. They do have a reason for it, and there is no doubt they (with their really high loads) need it. What does it mean for the rest of us? A little. All major PHP frameworks and CMS, including Drupal and Wordpress, cannot be compiled by HipHop. Moreover, PHP execution itself is a bottleneck in a very few cases, like Facebook’s, where data storage and other infrastructure is perfectly optimized. If your application works slowly, and you aren't getting loads comparable to Facebook’s, HipHop most likely will not help you. The problem is within the database or algorithms used.
Sources used: