After ongoing rumors of a new version of PHP being released by Facebook today, the company has officially announced HipHop for PHP: a source code transformer. For those who suggested that it was a new compiler, it isn’t exactly that. And no, Facebook has not rewritten PHP all together. While I don’t understand much about the technicalities behind compilers, Haiping Zhao has posted complete details about the project.
ipHop for PHP isn’t technically a compiler itself. Rather it is a source code transformer. HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features – such as eval() – in exchange for improved performance. 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.
Get it? Aside from understanding that the eval function will no longer be available, I don’t quite understand the new system. From an engineering perspective, HipHop for PHP is nothing short of phenomenal. Haiping Zhao started off developing the product as a service which could transform PHP code into C++. As he writes, “We knew that it was impossible to successfully rewrite an entire codebase of this size by hand, but wondered what would happen if we built a system to do it programatically.”
The project has taken two years: eight months to have a version that could be demonstrated, ten months finishing up all the coding, and six months testing the service on production servers. This evening the company will be hosting live streamed tech talk to discuss HipHop for PHP and what the project means for developers. If you have a service which handles hundreds of millions of monthly users (not likely) or just have an interest in impressive software engineering feats (more likely), you can tune in via the Facebook blog post.