Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

Exotic PHP implementations: HippyVM, JPHP, Tagua VM, Peachpie

Traditionally PHP code is ran on the official PHP implementation, officially known as Zend PHP. Since the launch of Zend Engine 1.0 in PHP 4 way back in the year 2000 Zend has evolved significantly, but deep down it's still the same scripting engine written in the C language.

With the launch of PHP 7.0 in late 2015 Zend Engine III added both new features and offered significant performance improvements. Being up to two times as fast in real life applications without code changes is a big win.

In the past there have been alternative environment for running PHP in PIPP for Parrot VM and Quercus for JVM, but none of these have had real staying power. This changed with HHVM from Facebook in the early 2010's. It's completely separate from the Zend PHP implementation and is a fully featured alternative.

HHVM is the only production ready alternative alternative to Zend PHP. It powers large sites like Facebook, Wikipedia and other sites. In addition to HHVM are other interesting efforts out there to run code written in PHP in novel ways.

Many the implementations are just proof of concept implementations and are far from supporting all the language features and rendering them to be useless for running Symfony or other contemporary applications.

Regardless of whether these are immedialy useful for projects it's interesting to follow these efforts. Now let's take a brief look at a few alternative approaches:

  • HippyVM, using RPython/PyPy
  • JPHP, using the Java Virtual Machine (JVM)
  • Tagua VM, using Rust and LLVM
  • Peachpie, using .NET and Roslyn

HippyVM: PHP on PyPy

HippyVM is a reimplementation of the PHP language using the high performance Python virtual machine, PyPy. It contains a reasonably complete implementation implementation of core features as well as popular modules.

HippyVM works so that it translates PHP code to RPython (Restricted Python), which in turn is analyzed and translated to native C code. This was a novel idea that was originally sponsored by Facebook, possibly as part of their exploration of alternatives to Zend Engine.

The project has been in limbo since early 2015 and is currently end of life.

JPHP: PHP on the JVM

The promise of JPHP is PHP on the Java Virtual Machine. The JVM is widely targetted by languages other than Java, including JavaScript, Ruby and Scala. PHP implementations have been around earlier, but have fizzled out in favour of the Zend Engine.

JPHP compiles PHP sources to JVM bytecode and then can execute the result on the JVM. JPHP does not aspire to be a replacement for Zend as it's ony a language implementations, libraries like PDO, Curl, and are not going to be developed. This means that you won't be able to run your favourite LAMP CMS on the JVM with JPHP.

Instead you can use the familiar PHP language syntax for creating applications that run on the JVM, enabling you to use Java libraries and classes in your PHP code as well as executing it on the Android, for example.

JPHP remains in active development. Due to the project goals it does not have the mass appeal that HHVM, for example had amongst mainstream web developers.

Tagua VM: PHP on LLVM

Tagua VM is a new project to provide a safe environment for running PHP code in a Virtual machine using the Rust language and the LLVM Compiler Infrastructure. It's a small project with high goals of regarding documentation, unit and integration tests, etc.

The implementation is written in Rust, a language focusing on safety by guaranteeing memory and thread safety. Together with the solid LLVM compiler infrastructure used by Apple's Swift and many others, Tagua VM has solid foundations for a new implementation of the PHP language.

Tagua VM is in active development, but at the moment it's more of a POC with limited functionality and only a handful of developers.

Peachpie: PHP on .NET

Peachpie is a new project to compile PHP to the .NET environment. It builds on the heritage of the older Phalanger project, but uses the new Roslyn Compiler platform from Microsoft. Similar JPHP, JVM and Java, Peachpie allows writing of hybrid applications that allow developers to write applications that are written in a mix of PHP and C#.

So Peachpie allows PHP to be executed within .NET. In the olden days this would have meant that you'd be targetting Windows platforms only, but now with .NET being Open Source it's possible to run Roslyn on Linux or a Mac.

The Peachpie project is only a few months old. It stems back to 2005 through the Phalanger, which has been able to run PHP applications like WordPress (WP.NET) since 2012. This is why Peachpie has the potential to run many existing PHP applications in the near future.

Conclusion

PHP 7 and HHVM will remain the most popular implementations for PHP for the unseeable future, but there are viable alternatives being in the works. So in addition to the PHP language itself and applications written in PHP continue to evolve - so do the environments where the language and applications are executed in.

It will be interesting to see how novel approaches to running PHP with PHP-PM will work together within a .NET environment through Peachpie for example.

Read more:


Written by Jani Tarvainen on Monday April 25, 2016
Permalink - Tags: php, hhvm, jphp, hippyvm, taguavm, peachpie

« PHP-PM grows up to be a credible option for high performance PHP - Use the Sylius Flow Bundle to create stepped flows in Symfony applications »