P++ and the future of PHP

Thomas Schoffelen

The PHP working group has proposed to create a new dialect of PHP. What does that mean for developers, and is it a smart thing to do?

ElePHPant, the PHP mascot. Image by Ulf Wendel.

I wrote (or, to be more accurate, copied and pasted) my first lines of PHP code when I was 11 years old. After doing some basic HTML and CSS, PHP was the first ‘real’ programming language I learned.

Over the past few years Javascript has started to take up a ton of my time in my day-to-day work (building React and React Native apps and Node.js microservices). However, I still consider PHP to be the language I know the most about, including all of the little weird intricacies of the language ($needle, $haystack anyone?).

Last month, some people within the PHP internals team — the team of open source collaborators that actively develops PHP — proposed a new version of PHP called P++ (working title). P++ is supposed to resolve a growing devision between members of the internals team regarding the future of the language.

A brief history of PHP

Rasmus Lerdorf started development of an early version what would become PHP in 1994. It was a way to create HTML pages that were dynamically rendered with snippets of C code through a set of CGI scripts.

With a growing community and more and more standard functions being added, PHP soon grew out to be a real programming language with the launch of PHP 3 and 4, the latter being released in May of 2000, and being close to what we now know as PHP.

PHP 5 was released four years laters, with more support for object-oriented programming (classes, methods, etc.) and made it easier to run PHP on Windows servers.

In 2004, development started on what was supposed to become PHP 6, which was supposed to provide native unicode support. Due to performance problems caused by these changes and a shortage of developers, this project was ultimately cancelled. A number of new features developed for PHP 6, like namespace support and closures, were ported over to PHP 5.3.

The first officially released major version of PHP after PHP 5 was released in 2015, and named PHP 7.

Static, dynamic, static, dynamic…

Recent releases of PHP have brought in many features that are supposed to make development safer by introducing typed function arguments and typed fields.

Many more features and improvements to make PHP a stricter language with less backwards compatibility bagage have been proposed in recent years, but the core development team seems to be divided over whether this takes the language in the right direction. There’s a large number of people in the PHP community that would rather keep PHP more or less how it currently is — dynamic, easy to learn, and with an overall emphasis on simplicity.

To resolve this divide, a new dialect of PHP is proposed that would be shipped together with PHP, which would provide less backwards compatibility, implement several new strict language rules and allow more advanced features to be implemented without affecting the ‘core’ PHP language for those that want to continue using it. You would enable this dialect for your code on a per-file basis by adding something at the top of the file like this:

<?p++?>
<?php 'Hello, world!'; ?>

Wait, hasn’t that already been tried?

In 2014 Facebook released the Hack language, an alternative version of PHP for their HipHop Virtual Machine (HHVM). Hack supports advanced type annotations, generics and several other features native PHP does not support.

Although still in use at Facebook and actively being developed, it hasn’t gained much traction over the course of the past few years.

So how is this P++ proposal different from Hack? Why would it succeed? According to the PHP maintainer proposing this dialect:

  • Being supported by the core PHP community will help it gain traction.
  • It will installed by default everywhere PHP 8 (or whatever version it will be shipped with) is available. This should make it easier for developers to get started using P++.
  • It won’t be a fork of PHP, but simply an extension that shares much of the same internals, and therefore doesn’t require a completely separate team of developers working on it.

Is this the right approach?

I don’t think so. PHP is already not the most popular language under most developers, seen as a ‘toy language’ by developers that last gave PHP a go pre-PHP7 and pre-Composer, or who’ve only ever seen the source code of Wordpress.

Even if this isn’t technically a fork of PHP, it will probably be seen as such by the developer community, who might be hesitant to start using it for the first few years out of fear that the project might die due to lack of interest or resources from the core development team, or due to the earlier experiences with things like the PHP 6 debacle.

I’m also not completely convinced if there is a great wish for a more strongly/strictly typed version of PHP from outside of the internals team. I think most PHP developers write PHP because it is a simple and flexible dynamic language. Does that come with some quirks? Sure, and ‘some’ might be slightly too generous. Most of the PHP audience happily accepts that as a cost for the simple nature of the language.

I do see a need for better tooling around detecting possible type problems and improving code, but a bigger investment in tools like phan would go a long way and achieve more, in my opinion, than adding a second dialect and having to explain new programmers that their code might behave differently based on the headers of their files.


If you want to read more about the P++ proposal, have a look at the FAQ on the PHP wiki.

Thomas Schoffelen

Written by

Entrepreneur tech kid, co-founder of NearSt, Londoner, open source enthusiast and aspiring spare time literature geek.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade