PHP VS Node.js  : An epic battle for developer mindshare

PHP VS Node.js : An epic battle for developer mindshare

It’s a classic Hollywood plot: the battle between two old friends who went separate ways. Often the friction begins when one pal sparks an interest in what had always been the other pal’s unspoken domain. In the programming language version of this movie, it’s the introduction of Node.js that turns the buddy flick into a grudge match: PHP and JavaScript, two partners who once ruled the internet together but now duke it out for the mind share of developers.

In the old days, the partnership was simple. JavaScript handled little details on the browser, while PHP managed all the server-side tasks between port 80 and MySQL. It was a happy union that continues to support many crucial parts of the internet. Between WordPress, Drupal, and Facebook, people can hardly go a minute on the web without running into PHP.

Then some clever kid discovered he could get JavaScript running on the server. Suddenly, there was no need to use PHP to build the next generation of server stacks. One language was all it took to build Node.js and the frameworks running on the client. “JavaScript everywhere” became the mantra for some.

Since that discovery, JavaScript has exploded. Node.js developers can now choose between an ever-expanding collection of excellent frameworks and scaffolding: React, Vue, Express, Angular, Meteor, and more. The list is long and the biggest problem is choosing between excellent options.

Some look at the boom in Node.js as proof that JavaScript is decisively winning, and there  is plenty of raw data to bolster that view. GitHub reports that JavaScript is the most popular language in its collection of repositories, and JavaScript’s kissing cousin, TypeScript, is rapidly growing too. Many of the coolest projects are written in JavaScript and many of the most popular hashtags refer to it. PHP, in the meantime, has slipped from third place to fourth in this ranking and it’s probably slipped even more in the count of press releases, product rollouts, and other heavily marketed moments.

But hype fades and software can live on for decades. Most of the PHP code base isn’t going to migrate and it continues to serve up large portions of the text we read each day. By some estimates, 40 percent of the pages we view begin, in some form, with PHP. Part of this is because PHP continues to be reborn. In the last few years, the guts of the systems running PHP have been completely rewritten. It’s not the same PHP code that ran your grandparent’s website.

PHP’s zippy, just-in-time compiler is delivering answers faster than ever thanks to the same smart techniques that powered the Node.js revolution. Now PHP 7.2 and the HHVM offer many of the same clever on-the-fly optimizations that V8 brought to Chrome and Node.js. Not only that, but HHVM has Hack, a clever PHP dialect that offers full support for sophisticated programming features such as lambdas, generics, and collections. So if you need these features, you don’t need to search for a more full-featured stack.

Of course, the ending isn’t written yet. For every coder crowing about the purity and youth of Node.js and the simplicity of JavaScript everywhere, there’s another who’s happy with the deep code base and long-understood stability of PHP. Will the old codger beat back the server-side upstart? Will JavaScript topple its old friend to achieve world domination? Put another batch of popcorn in the microwave and sit back.

1 thought on “PHP VS Node.js : An epic battle for developer mindshare”

Leave a Comment