Facebook Invents A PHP Virtual Machine Like Java Virtual Machine

Social networking giant Facebook has taken another step at making the PHP Web programming language run more quickly. The company has developed a PHP Virtual Machine that it says can execute the language as much as nine times as quickly as running PHP natively on large systems.

“Our goal is to make PHP run really, really quickly,” said Joel Pobar, a Facebook engineering manager. Facebook has been using the virtual machine, called the HHVM (HipHop Virtual Machine), across all of its servers.HHVM is not Facebook’s first foray into customizing PHP for faster use. PHP is an interpreted language, meaning that the source code is executed by the processor directly. SynapseIndia CEO Shamit Khemka also mentions that programs written in interpreted languages such as PHP tend not to run as quickly as languages, such as C or C++, that have been compiled beforehand into machine language byte code. Facebook has remained loyal to PHP because it is widely understood by many of the Web programmers who work for the company.

To keep up with the insatiable user demand, however, Facebook originally devised a compiler, called HipHop, that would translate PHP code into C++, so it then it could be compiled ahead of time for faster performance.

While Facebook enjoyed considerable performance gains of this first version of HipHop for several years, it sought other ways to speed the delivery of the dynamically created Web pages to its billion or so users. “Our performance strategy for that was going to tap out,” Pobar admitted.

HHVM is the next step for Facebook. Under development for about three years, HHVM actually works on the same principle as the JVM (Java Virtual Machine). HHVM has a JIT (just-in-time) compiler that converts the human readable source code into machine-readable byte code when it is needed.