Another one of those popular online tech debates that started over a year ago when PHP7 launched. PHP didn’t take much time to become one of the biggest assets for open source development. But PHP5 eventually got a rival in the form of HHVM (HipHop Virtual Machine), a virtual tool developed by Facebook that can execute PHP code far more effectively than other tools.
The contest took a turn when the latest version of PHP – PHP7 arrived. It outclassed its predecessor in many ways.
And so the showdown began. To come to a conclusion, we need to see what the contenders brought to the table.
Developed by tech giant Facebook in 2010, and released in 2011, the main purpose of HHVM was to reduce server resources so as to deliver a better experience for Facebook users. It does just that by converting PHP code into machine code quickly and efficiently. However, there are merits and demerits that we need to consider.
- Just in Time (JIT) compiler – the main reason how HHVM surpassed PHP5 in performance
- Any developer can install and work with it
- Doesn’t require much memory space to execute requests
- Hack – an internally developed programming language that allows programmers to use static as well as dynamic typing. Considerably improves compilation speed.
- Reliable community support for the developers to keep improving the tool.
- Websites can run faster in most situations due to dynamic translation.
- Custom extensions should be converted prior to adding them
- Does not support all WordPress plugins and themes
- Designed for high-end machines, and will not work on 32 bit operating systems
- Requires a lot of memory. The machine running it will need at least 2 GB RAM.
- If Facebook ceases HHVM support, the large development community will soon disappear.
PHP6 development took too long, and was riddled with many issues consequently giving it a bad reputation before its release. PHP6 eventually ended up in the trash, and was replaced by PHP7 that delivered a massive performance boost over PHP5.
- Many new programming language features including new operators, return type hinting, uniform variable syntax etc.
- Streamlined internal data handling made it almost 4 times more memory efficient than PHP5.6
- Established communities that offer technical support and troubleshooting assistance.
- Quicker response to requests with double the request handling limit compared to PHP5.6
- Lacks support for many PHP4 features
- HHVM is better when it comes to certain performance metrics
- Does not support some application plugins and themes
- Not recommended for high-traffic websites
Now, let’s get ready to rumble.
You can find performance comparisons of the two all over the internet. But it probably won’t help you get to a conclusion. Both contenders definitely outperform the older PHP versions. However, in certain instances one is better than the other. The methodology should be the critical factor here when you are assessing benchmarks.
The way they interpret PHP code is fundamentally poles apart. PHP7 uses PHP interpreter to translate and execute PHP codes. HHVM converts PHP code to HipHop bytecode, which is then interpreted and optimized as machine code and executed.
Benchmark tests by Kinsta in WordPress showed HHVM processing and executing 624 requests per second while PHP7 managed to execute only 604 requests. However, PHP7 had a more distinct advantage in Drupal 8, evident from the benchmark test. PHP7 managed 37% more server requests per second than HHVM. [Source: Kinsta]
Tests on various CMSs including Magento 2 community edition, Pyro CMS etc. indicated that HHVM is a better performer than PHP7. PHP7 was faster in Laravel 5.1 though.
When it comes to reduced overall memory usage, PHP7 takes the prize. HHVM demands comparatively more memory, in turn constraining server selection. Nevertheless, HHVM WordPress websites still consumed fewer CPU resources. However PHP and HHVM showed evenly matched performance on site load time tests.
Conclusion and Verdict
If you have used PHP5, you will easily notice the performance improvements in PHP7. However, your choice will ultimately depend on your requirements and your capacity. For high traffic websites running on multi-core servers, HHVM is the right choice. If you are just looking for something significantly better than PHP5, PHP7 is the way to go.
Software development is at its best if it helps a lot of people or a huge community. Keeping that in mind, HHVM basically is a more selfish alternative. It’s not shared much for the community to use it the way they want to. PHP, on the other hand, is a tool that’s constantly being improved for everyone to use, and is a more generous alternative. Experts claim that the support PHP is getting now, and the small pieces of incremental enhancements should help PHP7 emerge the victor of this bout eventually in terms of performance.
Verdict: HHVM wins for now. But a future rematch will most likely have different results.