Supporting the features of PHP7 through HHVM, an Open Source Virtual Machine

schema1PHP is growing at a rapid pace, with the version 6 being replaced unsystematically we can deduce on how far the robust requirements are making a kill. Not very long since PHP7 made its debut, there is a new buzz about HHVM.

What is HHVM?

HHVM which stands for HipHop Virtual Machine has an open source status and is used for executing HACK and PHP programs. One of the special features of HHVM is, that it uses JIT aka just-in-time compilation process for code execution. JIT compiler converts PHP code into a machine code to ensure faster execution process.

Since PHP is an interpreted language, the execution process suffers latency incase of dynamic applications. In interpreted language the source code is not directly run by the machine, instead it is converted in to an interpreter code which is run by an interpreter. Again, this code is converted to machine specific by the interpreter.

This intermediate code is known as PHP bytecode will be stored in bytecode cache. The bytecode cache will be vulnerable and can be lost in case of a server restart. But under HHVM, this bytecode cache survives. Even though HHVM supports PHP7, there is word that the performances of these two are being compared. The reason behind this action is, since both PHP7 and HHVM executes PHP code, the way in which the code is being interpreted is highlighted.

PHP7 Vs HHVM

Before PHP7 made an entrance it promised to provide better data security, robust performance and reduced memory consumption over PHP5. PHP7 true to the words fulfilled the promise by efficiently supporting all the dynamic applications. Somewhere in the line HHVM made a better contribution for the performance phase through the process of code interpretation.

Under PHP7, the PHP code is directly interpreted and executed, while under HHVM, the PHP code is converted to Hip Hop bytecode before being translated to machine code and final execution. Through this course all the drawbacks of code will be nullified, hence there will be a huge performance growth. Here are few highlights that differentiates between the characteristics of PHP7 and HHVM,

  • Memory-When multiple requests are made HHVM consumes comparatively lesser memory than PHP7.
  • Performance- HHVM supports more transactions per second than PHP7.
  • Type Hinting-It is process of specifying the required data type in function declaration.
    Under PHP7 there are two types of type hinting, weak and strong, where weak typed is the default mode. Suppose you need a conversion to strong typed mode, then a declaration is to be done at the begging of a source file. Also, this action is not supported in configuration files and default mode will remain as weakly typed.
    But under HHVM, the default mode will always be strongly typed mode. Apart from this nullable and mixed types are also supported.
  • Language Specifications-Lambdas, Generics, Enum, tuples and shapes are the original language specifications which ensure faster code development with minimum bugs.

Better user-experience, well, this is what Facebook had as its target. When the number of users increased rapidly, Facebook introduced HHVM in PHP to efficiently manage the traffic.

Web technology is fast evolving; from static to dynamic we have seen a rapid development in the approach from developers. Through compiling HACK and PHP programs in to bytecode, HHVM is ensuring optimization in the overall performance.