I came across an article titled “PHP vs. Node.js: An epic battle for developer mindshare” and articles like that bug me. I like that they are talking about developer mindshare, because mindshare can really impact the quality of tools and end results from a given platform. But posts like “this tool is better than that” don’t help developers choose the right tools for the right job, or help clients understand the big picture. So I thought I’d share my take on the topic.
The Mainframe is Dead
Back in the bad old days of computing, computers were so expensive that it made sense to have one really big computer with many “dumb” terminals. The big computer, the mainframe, did almost all the work. When personal computers and the internet started becoming widespread, it shook that model to the core, and PHP was part of that vanguard. Suddenly users were sitting at powerful workstations instead of dumb terminals, and the role of the mainframe became one of dishing out content (called HTML) instead of the entire application. The web browser was the application, and PHP was a great tool to deliver content to it.
Why it Doesn’t Matter
Every language sucks. Except when it is used for its intended purpose. Comparing tools designed to do different jobs doesn’t help anyone- and Node.js isn’t designed to shuttle HTML content from the server to the web browser. It can; quite well in fact. But that’s not what it’s good for. Node was written to be a lightweight network services tool. It was conceived for fast processing of discrete network messages. The reason it gets lumped in with web development technologies is because that’s basically what a web server does. It’s just that Node is so much more than a web server.
Node can serve up HTML, or it can serve up data, or provide an API for managing a network or data center. It can scrape websites or process files… it’s a nice tool for doing behind-the scenes work. All that is to say: it’s not a direct competitor to PHP.
But I can also say that I really like PHP. It’s given us amazing tools which set the bar high, like WordPress, Drupal, and countless others. There aren’t any Node.js content management systems that hold a candle to the venerable stable that PHP boasts.
And that’s completely ok, for both languages.
The Web of Tomorrow
Just as the World Wide Web disrupted the mainframe computing model, modern web apps are changing the way people use computers, and by necessity, the tools that power them. These days people surf the web with phones, watches, even refrigerators. PHP has been (and still is) a wonderful tool for conventional websites. But more and more sophisticated web apps demand newer and more specialized tools. For instance, single-page-apps don’t consume HTML files, but raw data from an API. PHP can provide that API, and quite well, but that’s not really what it was designed to do. Node on the other hand, was designed for just that.
So when you read an article proclaiming the superiority of one language or platform, remember: you can’t compare apples and oranges.