HipHop Virtual Machine
|Initial release||December 9, 2011|
|Stable release||3.2.0 / July 18, 2014|
|Written in||C++, C|
|License||PHP License and Zend License|
|As of||August 2014|
HipHop Virtual Machine (HHVM) is a process virtual machine based on just-in-time (JIT) compilation, serving as an execution engine for PHP and Hack programming languages. By using the principle of JIT compilation, executed PHP or Hack code is first transformed into intermediate HipHop bytecode (HHBC), which is then dynamically translated into the x86-64 machine code, optimized and executed – as opposed to the PHP's usual execution path of PHP code being transformed into opcodes and interpreted.
HHVM is created as the successor of the HipHop for PHP (HPHPc) PHP execution engine, which is a PHP-to-C++ transpiler also created by Facebook. Based on the gained experience and aiming to solve issues brought by HPHPc, in early 2010 Facebook decided to create a JIT-based PHP virtual machine. Issues associated with HPHPc included its flattened curve for further performance improvements, lack of full support for the PHP language, and difficulties related to specific time- and resource-consuming development and deployment processes. In Q1 2013, the production version of facebook.com switched from using HPHPc to HHVM.
Following the JIT compilation principle, HHVM converts executed PHP or Hack code into HHBC as a high-level bytecode, which is also known as intermediate language. HHBC is a bytecode format created specifically for HHVM, in a form that is appropriate for consumption by interpreters and just-in-time compilers. HHBC is then dynamically ("just-in-time") translated into the x86-64 machine code and executed, with additional optimizations performed through dynamic analysis of the translated bytecode. In these respects, HHVM has certain similarities to the virtual machines used by other programming languages, including the Common Language Runtime (CLR, for the C# language) and Java virtual machine (JVM, for the Java language).
HHVM brings many benefits over HPHPc; one of them is almost complete support for the entire PHP language as defined by its official 5.4 version, including the support for create_function() and eval() constructs. Also, with HHVM there is only one execution engine for both production and development environments, meaning that maintaining HPHPi separately is no longer required, and there exists both production and development integration with HPHPd. At the same time, development and deployment processes are much simpler when compared to HPHPc, as the lengthy binary build time is no longer present.
Together with HHVM, Facebook also released Hack, a programming language specifically tailored for HHVM that can be seen as a new version of PHP. Hack allows programmers to use both dynamic typing and static typing (a concept also known as gradual typing), and allows types to be specified for function arguments, function return values, and class properties; however, types of local variables cannot be specified. At the same time, Hack does not carry on some of the PHP features.
As a process virtual machine that provides the execution environment, HHVM has the ability to use live type information to produce more efficient native code, leading to higher web server throughput and lower latency. In Q4 2012, the performance of facebook.com code running on HHVM achieved parity with HPHPc, while in December 2013 it was even surpassed by around 15%.
- Jason Evans (December 9, 2011). "The HipHop Virtual Machine". Facebook. Retrieved August 2, 2014.
- HHVM-3.2.0. "facebook/hhvm". github.com. Facebook. July 18, 2014. Retrieved August 2, 2014.
- License. "facebook/hhvm". github.com. Facebook. Retrieved August 2, 2014.
- "facebook/hhvm". github.com. Facebook. Retrieved August 2, 2014.
- Drew Paroski (November 29, 2012). "Speeding up PHP-based development with HHVM". Facebook. Retrieved August 2, 2014.
- "Announcement on GitHub removing HPHPc support". github.com. Facebook. February 19, 2013. Retrieved May 24, 2013.
- "HipHop Bytecode v1 revision 18". github.com. Facebook. July 31, 2014. Retrieved May 24, 2013.
- About upgrade to PHP 5.4 engine. "facebook/hhvm". github.com. May 2013. Retrieved August 2, 2014.
- Home. "facebook/hhvm". github.com. Facebook. May 8, 2014. Retrieved August 2, 2014.
- Cade Metz (March 20, 2014). "Facebook Introduces 'Hack,' the Programming Language of the Future". Wired. Retrieved April 15, 2014.
- Julien Verlaguet; Alok Menghrajani (April 2014). "Hack: a new programming language for HHVM". code.facebook.com. Facebook. Retrieved March 23, 2014.
- Josh Lockhart (April 3, 2014). "Facebook’s Hack, HHVM, and the future of PHP". O'Reilly Media. Retrieved August 2, 2014.
- Hack and HHVM: Type Annotations. "Hack Manual". docs.hhvm.com. Retrieved March 25, 2014.
- Hack and HHVM: Type Inference. "Hack Manual". docs.hhvm.com. Retrieved March 25, 2014.
- Hack and HHVM: Unsupported PHP Features in Hack. "Hack Manual". docs.hhvm.com. Retrieved April 2, 2014.
- "We are the 98.5% (and the 16%)". hhvm.com. December 19, 2013. Retrieved August 2, 2014.
- Official website
- HHVM source code on GitHub
- Internals of HHVM – a talk given by a HipHop engineer, Keith Adams, at QCon 2012
- HHVM Talk to Wikimedia in March 2013 – a talk given by a HipHop engineer, Andrew Paroski, at Wikimedia
- Scaling with HipHop on YouTube – a talk given by a HipHop open source engineer, Sara Goleman, at PHP UK Conference 2013
- Official HHVM blog