Again facebook development team comes with a super development. Its HipHop for PHP. HipHop for PHP in simple terms is a code transformer that transforms PHP code into optimized C++ and then g++ compiler to compiles this. Facebook writes in its official blog that with the help of HipHop they have reduced their CPU usage upto 50% and hence they are able to scale facebook upto such a large scale.
HipHop includes a code transformer, a reimplementation of PHP’s runtime system, and a rewrite of many common PHP Extensions to take advantage of these performance optimizations.
“PHP’s roots are those of a scripting language, like Perl, Python, and Ruby, all of which have major benefits in terms of programmer productivity and the ability to iterate quickly on products. This is compared to more traditionalcompiled languages like C++ and interpreted languages like Java. On the other hand, scripting languages are known to generally be less efficient when it comes to CPU and memory usage. Because of this, it’s been challenging to scale Facebook to over 400 billion PHP-based page views every month.” Says Haiping Zhao on his official blog on facebook.
And how HipHop works
The transformation process includes three main steps:
- Static analysis where we collect information on who declares what and dependencies,
- Type inference where we choose the most specific type between C++ scalars, String, Array, classes, Object, and Variant, and
- Code generation which for the most part is a direct correspondence from PHP statements and expressions to C++ statements and expressions
HipHop has been developed on CentOS and Fedora.
For more information visit -