PHP Classes

PHP Core Developers versus Facebook: Round 3 - The PHP Specification

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog PHP Core Developers v...   Post a comment Post a comment   See comments See comments (6)   Trackbacks (0)  


Viewers: 40

Last month viewers: 13

Categories: PHP community, News, PHP opinions

Recently Facebook developers played on another episode of a saga that seems to antagonize Facebook and PHP Core developers.

This time they announced an initiative to create a formal specification document for the PHP language.

Read this article to learn more about this and previous episodes of this saga, and what this may mean for the PHP future.

Loaded Article


The PHP Core Developers and the Facebook Saga

Round 1: The HipHop Compiler

Round 2: The Facebook Hack Language

Round 3: The PHP Specification

A PHP Specification Leverages the Benefits of TDD

The Implicit Competition between PHP Core Developers and Facebook

Advice to Facebook

1. Stop Acting Secretly

2. Cooperate Closely with Zend

3. Share Your PHP Tools


The PHP Core Developers and the Facebook Saga

Facebook is a large company. Its site is the largest deployment of PHP on the planet.

Therefore it is natural that Facebook takes the investment on PHP very seriously. So seriously that they have been investing on taking the most of PHP to make Facebook site as fast as possible, taking the least resources as possible.

Round 1: The HipHop Compiler

In 2010 Facebook launched the HipHop PHP compiler. The idea was to generate C++ code that is equivalent to the original PHP code, so it could be compiled into native machine code and eventually run faster.

Another benefit is that HipHop could also generate a whole Web server executable that could work by itself without needing a separate Web server.

The main advantage of this Web server is that it would handle multiple simultaneous requests using threads, rather than forked processes, so it would eventually save RAM, as multiple requests would share the same memory pool and they could also minimize the number of opened database connections using a single connection pool.

One odd thing is that for the Hiphop launch event, Facebook invited some PHP core developers. Maybe I am reading to much from this detail, but it pretty much sounded like Facebook was teasing PHP core developers, like saying, here is a new PHP implementation that we are using because it is better than the original based on Zend Engine.

You could interpret this tease as if Facebook was saying that PHP should either adopt HipHop PHP or do better. Neither of the options happened.

Meanwhile Facebook ditched HipHop PHP compiler to C++ and replaced it by a dynamic JIT compiler virtual machine later called HHVM because HipHop PHP compiler was not really that much efficient. It was taking too much time to generate optimized binaries and the performance improvement in real applications was not that great.

Round 2: The Facebook Hack Language

Early in 2014 Facebook announced a new language backwards compatible with PHP called Facebook Hack.

It allows to mix your original PHP code with new Facebook Hack language constructs that introduce important new features like explicit type declarations for variables, function parameters and return values, as well a new construct to run multiple code segments in parallel within the same process.

The type declaration is optional but when you use it, it allows HHVM JIT engine to generate native machine code that runs faster. This is a feature that I antecipated in 2012 that would be necessary to make PHP code run faster.

The feature to run parallel code segments is quite surprising as it provides the features of asynchronous programming without dealing with the callback hell like you have to deal with Node.js.

This feature of Facebook Hack may have been inspired in the Go routines of the Go language as we discussed in a recent episode of the Lately in JavaScript podcast, as well of the Lately in PHP podcast (to be published soon).

More recently, PHP core developers have been working on special enhancements of the PHP engine in a branch currently called PHPNG. It seems to have been started before the Facebook Hack public announcement, but it still looks like it was a reaction of Zend to bring PHP on par to HHVM JIT.

According to Dmitry Stogov of Zend, the goal of this branch was to evaluate bringing a JIT engine based on LLVM to the next PHP generation. This branch sparked the development of other types of optimizations that will benefit the current Zend Engine based PHP regardless of whether the JIT engine is enabled.

Round 3: The PHP Specification

Recently, Sarah Golemon, a long time PHP core developer now working for Facebook, came up with a proposal for a draft of a document that aims to be a specification for the PHP language.

The idea to have a specification for the PHP language is great. It is not a new idea. It was suggested some time ago but nobody moved forward with it then, because it is not a trivial effort.

A PHP Specification Leverages the Benefits of TDD

The reason why a specification for the language is great because it defines clear rules for implementations of the language. This allows to create test scripts that verify if each implementation works as intended.

A specification even allows to implement what is called TDD (Test Driven Development), meaning creating tests for new versions of the language even before the code for any implementations is available. Coincidentally I have mentioned this on a recent article about why TDD failed to become mainstream.

Having a specification is precisely a situation on which TDD is not only recommended, as well it is highly desirable, because it allows implementers to catch and fix earlier the bugs of their implementation. This way it minimizes the existence of discrepancies between different PHP implementations.

The Implicit Competition between PHP Core Developers and Facebook

On the other hand, having a specification before any implementation means that any of the implementers can develop their implementation before the other implementers. This means in practice that for instance Facebook can make their implementation of the next PHP version available even before there is a Zend Engine based version available of the same specification.

Although this may sound fine for the PHP users in general, this circumstance may cause some concern among PHP core developers regarding the intentions of Facebook.

Advice to Facebook

Maybe Facebook does not really have bad intentions but some of their moves make PHP developers wonder and refrain from cooperating with them. If I was in charge at Facebook, I would do the following to regain trust and cooperation with PHP core developers.

1. Stop Acting Secretly

Recently a video of a talk that Stefan Priebsch gave in the International PHP Conference exposed that Facebook has been working secretly on Facebook Hack since last year. He mentioned that he and Sebastian Bergmann were required to sign an agreement that they refused because they found the conditions unacceptable.

I don't know why Facebook is acting secretly when they develop Facebook Hack. Do they fear to be copied by any competitor? Do they fear that Google, Apple or Microsoft develop anything that may compete with them?

Facebook Hack is not a product that they sell. So who could benefit of knowing in advance of Facebook Hack plans?

Google could use Facebook knowledge to build a better PHP to run on PHP App Engine cloud hosting platform. Unless Facebook is planning to enter on the cloud hosting business, I do not see any threat from Google to Facebook.

Microsoft also runs PHP on their Windows Azure cloud hosting platform. It does not seem that Microsoft is interested to develop a competitor implementation of PHP for Windows. They even hired the Phalanger team in the past, but they did not foster the development of Phalanger itself.

2. Cooperate Closely with Zend

If there is any competition to Facebook Hack, that is the Zend Engine based PHP. While Zend Engine is not PHP, there are stronger ties from PHP core developers to Zend Engine than anything else.

For instance, there are many PHP extensions around that rely on the Zend Engine to work. The effort to make them work with Facebook Hack is too big to be considered. Those extension developers are not willing to give up on Zend Engine based PHP for an alternative implementation on which their extensions do not work.

So instead of creating a competing implementation of PHP, Facebook efforts would get more acceptance if Facebook made an effort to integrate their work in the Zend Engine based PHP.

Zend has also been working secretly on the PHPNG branch. That seems to have been a reaction to the fact that Facebook has also been working secretly in PHP alternative implementation since their first release of HipHop PHP compiler.

Maybe there are reasons for Facebook to act secretly that I have no knowledge. But if that is not really the case, I am sure a closer cooperation with Zend would be much more beneficial to Facebook, Zend and the PHP community in general.

For instance, instead of working in separate projects, Facebook could show some good faith and lend developers to make the PHP core move faster with the next PHP version. They could follow the example of SmugMug that is paying for a full time developer (Michael Wallner) to work on the PHP core.

3. Share Your PHP Tools

Recently, Rasmus Lerdorf (the creator of PHP) expressed the desire that Facebook shares their PHP static analysis system as standalone tools with the PHP community in general. This is a topic that was also mentioned in the Stefan Priebsch talk above.

If those tools are really good for Facebook, I think the PHP community would see it as an act of good faith if Facebook made it easy for the PHP community in general to use those tools too.


I suspect that this story of Facebook and the PHP core developers is not any close to be over. More episodes are expected to come but I have no clue what they will be about.

I hope that Facebook comes closer to the PHP core developers, so the PHP community as a whole can benefit from a more extensive cooperation. Lets see what the next episodes get us.

You need to be a registered user or login to post a comment

1,602,182 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:



3. nice writeup - Sriram (2014-07-28 09:30)
thanks note :)... - 1 reply
Read the whole comment and replies

2. Facebook looks likes itís trying EEE - Mike Ruiz (2014-07-26 04:14)
The Triple E Strategy Starts?... - 1 reply
Read the whole comment and replies

1. HipHop - michael hodgins (2014-07-25 11:56)
Minor correction... - 1 reply
Read the whole comment and replies

  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog PHP Core Developers v...   Post a comment Post a comment   See comments See comments (6)   Trackbacks (0)