Apr 14

HipHop is a tool that converts PHP code into C++ code that when combined with a PHP compatible engine and extensions library. According to Haiping Zhao (Developer at Facebook), It can speed up applications by 50%. Currently, Facebook is serving 90% of its Web traffic using HipHop.

Compiling PHP to C is not a new idea. There were some open source projects like PHC, Roadsend. However it seems that HipHop is the most ‘practical’ one among the others since it has been used to convert millions of lines of PHP in Facebook Server.

According to Facebook, the project was bridging the gap between PHP and C++ by static transformation. The transformation process includes three main steps:

1. Static analysis
2. Type inference
3. Code generation

The main step that they gain performance is type inference since PHP is a weakly typed language. When the variables are converted to corresponding specific types in C++, they require less memory.
There are some drawbacks that you need to consider before using HipHop in your porjects:

1- PHP 5.3 is not supported by HipHop. So, for now, forget about namespaces, late static binding if you decide to use HipHop.
2- Some functions like ‘eval()’ is not supported.
3- If you’re using PHP extensions that is not included in HipHop project, you need to convert them to C++ variants
4- If you’re a ‘PHP on Windows’ fan, you need to reconsider this since it doesn’t work on windows.

Check out HipHop wiki page for installation instructions and source code.

http://wiki.github.com/facebook/hiphop-php/

Tagged with:
preload preload preload