Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

Dear PHP, the times are a-changin'

The PHP community has been buzzing about all the significant releases such as PHP 7, Symfony 3 and Drupal 8 in 2015. With improved userland application frameworks, better performance and lower memory usage PHP is about to be better than ever.

Yet the world is changing and maybe PHP shouldn't (or can't) even try to keep up with the Joneses.

PHP has for the longest time been the top of mind programming language for mainstream and hobbyist Web Developers. It's running a large parts of the web, you're bound to be a PHP user if you've got an internet connection. It's everywhere and it's not going away any time soon.

During the years there have been as many "PHP Killers" as there have been "iPhone Killers" and "Google Killers". At some point Ruby on Rails was the thing that would dethrone PHP, because it was "better". Then there was Python with Django - where you could do no wrong due to the nature of the syntax. And then there's JavaScript which will make everything crazy fast, 'cos Node yo.

The PHP runtime itself has been challenged by Facebook's HHVM in the last few years. People are comparing charts of PHP 7 vs. HHVM performance, dreaming of low latency and high throughput. This and improvements in the language are good, but in the end it's just a better tool for server side scripting via HTTP or via Command Line. RoR and Django were sold as a replacement to do the same exact thing. Meh.

PHP has never been able to break out from being a server side language. There have been efforts to make PHP a viable Desktop Application Platform, but those have been awkward at best. Java, dreaded by many PHP developers is more versatile than PHP.

With Java you write passable desktop applications, you can write high performance data analysis and storage applications like ElasticSearch, Neo4J and JackRabbit. You can write plain old web application back ends as well with modern frameworks like Play. In addition Java likely powers your every day life embedded in mobile phones, printers, set top boxes, etc.

So PHP has failed to gain traction beyond it's niche in server side scripting. And that's fine. I have myself written that PHP has evolved to be a very good platform and still think it's great for writing back ends for applications for the long term. In the year 2020, I'd rather maintain an application built with PHP starting from 2015 than one with JavaScript. PHP is more mature for this task.

This brings us to JavaScript, the new sexy hunk of web development languages. Node.js is often praised for it's simplicity and performance, but in my opinion the significant shift is being able to genuinely share code between the client and the server. To the point that you can no longer (always) tell if you're writing code for the server or the client.

Some call these isomorphic applications, but I personally prefer the term Universal JavaScript. This won't be an overnight revolution; churning out sites with Drupal or WordPress will remain mostly the same. Some might say REST APIs are a game changer for these products. To me this is yet another protocol for data transfer and manipulation, not code sharing.

I'm sure people will continue to create all kind of kludges to stretch PHP beyond it's limits. Please stop, since it's just not a very good tool for many things out there. If you want to move beyond the limits of PHP with a similar language - take a look at Hack, an open source PHP derivative from Facebook.

Hack gives you a PHP like syntax, great tooling, native async and allows bridging the server and client side natively with XHP-JS. Also worth noting is that Hack and PHP can share HHVM as a runtime, just like Java and Scala share JVM. But with a maximum one year support cycle it's safe to say Hack does not compete with long stability with PHP.

So I'm not going to switch the H2O-HHVM combo this site is running to something like Ghost, just because NoSQL and Node. But for the first time since what feels like forever, I find myself seriously considering alternatives to PHP when starting fresh. Something universal, not bound by front end vs. back end Apartheid.

You've got your niche, but the times they are a-changin', old friend.

P.S. Heavily influenced by Pekkis' talk on the Long march to PHP 7 and Beyond


Written by Jani Tarvainen on Tuesday July 21, 2015
Permalink - Tags: php, javascript, hhvm

« Using Blackfire for debugging production environments - Learn Symfony with Silex, the Demo App and the Best Practices Book »