PHP vs Node.js Smackdown: Right of Reply

Share this article

The gloves are off: an arm wrestle of the editors
The gloves are off: an arm wrestle of the editors

In SitePoint’s recent PHP vs Node.js Smackdown, Craig Buckler pitted these development disciplines against each other over a series of ten challenges, to determine which is the overall winner.

As Craig notes in the article, these comparisons are always somewhat controversial. As a fun followup, we asked Bruno Škvorc (SitePoint’s PHP editor) and James Hibbard (one of SitePoint’s JavaScript editors) to provide a commentary on each of the rounds.

Here’s their blow-by-blow assessment …


Round 1: Getting Started

Round 1‘s challenge was to see how quickly you can build a “Hello World” web page in each language. This included the time taken to set up a server environment.

In Craig’s estimation, PHP won the round, partly because it’s “conceptually simpler” and “less daunting to new developers”.

Bruno:

PHP wins in “getting started” purely because more hosts have made it so easy to get started. It’s a matter of adoption rather than anything else. If more hosts bypassed the need to use the command line with Node and went straight to file uploads and a simple “reload app” button in a control panel, they would be equal. The actual syntax of getting something to display on screen, however, is much simpler in PHP — especially to those new to programming.

James:

When developing locally, I don’t see a huge difference between the two. To run a PHP script in your browser, you need to have some kind of server stack installed; to run a Node script, you need to have installed Node, and preferably a web framework such as express. However, as Craig says, PHP is conceptually simpler. Node’s barrier to entry is higher. No debate there.

Round 2: Help and Support

Round 2 looked at how easy it is to get help and support with each language. PHP wins this round, mainly because of its longevity.

Bruno:

Bruno kept silent on this one.

James:

I agree with this. Node.js is a younger technology, so currently, there is less help available. This will, however, become less and less of a consideration as Node matures.

Round 3: Language Syntax

Round 3 compared how easy it is to understand and use the syntax of PHP and JavaScript. Craig awarded this round to JavaScript.

Bruno:

I strongly disagree on this point. While PHP does have its quirks, many of them have been corrected in recent times and many oddities will be removed in the newest release. On the other hand, there’s this and this in the JS world.

Regarding bullet 3 (that your brain doesn’t need to switch modes because you can use JS on the client and server), I disagree. The server environment is completely different from the client one, and a switching of brain modes is required. There’s also new syntax that you can’t use in the browser, and vice versa, so it’s kind of like switching languages.

Bullet 4 (that understanding JS makes you want to use it more) is also something I disagree with. Having worked with both JS and PHP for years, the more I work with JS, the less I like it — though that’s purely personal preference.

James:

I love JavaScript. I know it has its quirks, and I know it has some gotchas, but ECMAScript 2015 will straighten a lot of this out, as well as bringing some exciting new features to the language. JavaScript is both powerful and flexible, and can accommodate many different styles of programming. In contrast to PHP, I enjoy writing JavaScript. Node deserved this one.

Round 4: Development Tools

Round 4 considered the tools available to each technology, with Node winning by a nose thanks to npm.

Bruno:

While Composer was originally inspired by npm, it’s now leaps and bounds better than it and won’t break your system if you have to install two versions of the same library, unlike npm. Also unlike npm, Composer can install recursive dependencies, something npm simply cannot do — yet something that is absolutely essential, and should be the very first thought in the head of someone setting out to build a package manager.

npm also has downright awful error messages that are what I like to call “core-developer friendly” — in that only those who wrote them can understand them. Finally, npm doesn’t play well with Vagrant, and effectively hinders you in getting started properly — not to mention that they don’t pay attention to their users’ desires. Here is a bug that’s been open for years, making it basically unusable on Windows — hardly a trivial user base. PHP has its share of stupid bugs too, but those don’t alienate an entire OS for years.

True, Composer isn’t bundled with PHP, but I don’t think it should be. Such favor shouldn’t be given to a package manager which is, literally, a separate app. If someone, some day, actually makes a good package manager for Node, it’ll be bureaucratic hell to switch it out for the current one, let alone get people to transition. Besides, installing it is literally one line in a terminal, or downloading an installer.

The statement that Composer has had less of an impact is plain wrong. Composer has influenced all of the new PHP devs coming on board the PHP train since it was developed, and most of the good ones who had to add it into their current workflow. Just because there were a lot of PHP users before Composer existed, doesn’t mean its impact is smaller. Ever since it was made, it has had a tremendous impact. Absolutist statements like “has made less of an impact within the community” shouldn’t be made without a factual backing.

I can’t argue with the fact that most PHP devs will install Node at one point, that’s true. Sadly, a lot of the good tools are being developed Node-first, but I remain hopeful for a Node-free development environment due to projects like BowerPHP.

James:

I’m glad this one went to Node.

I love npm. It’s easy to install, easy to use, and there are thousands of packages available for almost any need. I also like the fact that npm lets you choose between the global and local installation of packages (in contrast to languages such as Ruby, where it’s standard for your gems to be installed alongside your Ruby version). The tooling is also fantastic. Tools such as Bower and Grunt have a regular place in my workflow, and have increased my productivity many times over.

It’s also worth mentioning that npm v3 is out in beta. This addresses many of the points that Bruno raises, such as the nested node_modules approach bug.

Quote of the entire smackdown:

PHP developers will probably want/need to install Node.js at some point. The reverse isn’t true.

Round 5: Environments

Round 5 touched on where the technologies can be used and deployed, and which platforms and ecosystems are supported. Craig wasn’t explicit about his call on this one, but it looks like a wet sail for Node.

Bruno:

Craig said he would compare PHP’s and Node’s web strengths (general web development challenge) and then says JS is everywhere. Firstly, we’re comparing Node.js, not JS itself. Secondly, we’re comparing the languages and environments where they can run. Saying a monkey is better than a fish because the fish has failed to climb the tree is just silly. But both the monkey and the fish can swim, so let’s compare how well they do that.

In a web development environment, PHP wins hands down. There are tools for desktop development in PHP — and yes, true, you probably won’t use them. But you definitely will use the command line aspect of PHP.

James:

Again, I agree with Craig. Several of the features that are making Node.js so popular (speed, scalability, affinity with JSON, low resource usage) also make it well-suited for many other kinds of applications, for example powering IoT devices. I mean, who doesn’t love robots?

Node has also given rise to projects such as NW.js (an app runtime based on Chromium and Node.js) which allows you to write native apps in HTML and JavaScript. Exciting times!

Round 6: Integration

Round 6 looked at integration with databases and drivers, and PHP wins mainly because of its age.

Bruno:

Integration is a draw. PHP has an age advantage in this, giving it more options, but this also means it suffers from some severely outdated integrations like the mysql extension — which we’ve only managed to get rid of in PHP7, but which has been unusable for years.

James:

Not sure I agree with this. The whole round seems fuzzily worded, and I would have hoped for an example of “older, less-popular technologies”. This would also be a good opportunity to underline one of Node’s big pluses — that it speaks JSON. JSON is probably the most important data exchange format on the web, and is also the lingua franca for interacting with many of the latest NoSQL databases. JSON is ideally suited for consumption by a JavaScript program, meaning that when you’re working with Node, data can flow neatly between layers without the need for reformatting. You can have one syntax from browser to server to database.

Round 7: Hosting and Deployment

Round 7 looked at how easy it is to deploy new apps to a live web server, and in Craig’s view, PHP is the clear winner on this count.

Bruno:

Again, Bruno keeps quiet, having nothing to add.

James:

This is one area where Node has got a lot of catching up to do. Every budget web hosting company offers a PHP packet with MySQL thrown in. To see some kind of output, all you’ve got to do is create a file with a .php extension, shove some valid statements between <? and ?>, upload the file and point your browser at it. The same cannot be said for Node. There are, of course, many options for Node hosting, but they invariably require more set up and command line access, which is potentially off-putting for beginners. PHP wins this round hands down, no question.

Round 8: Performance

Round 8 focused on speed; and, although this can often come down to the experience and care taken by the development team, Craig noted the advantages of Node on a number of fronts.

Bruno:

Misconceptions abound. First, there is this post which renders all performance discussions moot. Any and all performance gains/losses depend exclusively on the experience of the devs and the type of app. But even if that post isn’t convincing you that performance discussions are stupid out of context, here are some of my own arguments:

  • PHP is getting a multi-threaded built-in server. This would make it possible to bypass an external server completely, but not recommended (yet). There are also super fast servers like Nginx which make the whole process of launching PHP and delegating requests to it unnoticeable.
  • Projects like HHVM and Appserver add powerful async and multithreading aspects to PHP, and PHP7 itself is getting some powerful upgrades in that department, too.
  • PHP’s single-request app lifetime is the biggest ankle-weight, yes, if you’re looking for raw speed; but this, too, can be easily circumvented, not only with Memcached and similar solutions as Craig states, but with methods like Ajax. By the way — server-side JS apps are single-request by default, too. What’s more — this single-request lifetime is also an advantage, in that it rebuilds the app every time it’s used, thereby avoiding memory problems, cleaning up garbage, and staying lean and clean. When was the last time you used a stable, long-running, memory-leak-free JavaScript application either on the back end or the front end?

Performance discussions are, and always will be, a draw. (Unless you’re dealing with Java — then Java always loses! ;) )

James:

Node is touted as the runtime of choice for high-performance, low latency applications, and has already found its way into the code stacks of several Fortune 500 companies. Thanks to its non-blocking I/O mechanism and Google Chrome V8 engine technology, it has become synonymous with the words “fast” and “scalable”. There are numerous stories online about how Node brought serious performance gains to companies and lead to greater developer productivity. I’m happy to see this one go to Node, but understand that it’s a contentious point.

Round 9: Programmer Passion

Round 9 looked at Craig’s perception of how much passion developers are currently showing for PHP and Node, and in his estimation, Node wins hands down.

Bruno:

You are definitely looking in the wrong places, Craig. The PHP community is incredibly passionate and very active. There are over 20 big conferences per year, and some amazing topics get discussed. The treading of water has finished with the advent of HHVM and PHP7.

Additionally, I would say that it’s curious that Node’s developers still haven’t learned how version numbers work (version v0.12.5 at the time of writing), even after 6 years in development. That kind of immaturity and desperate “playing it safe” (whoops, you used something that’s unstable, your fault it broke your company lol), coupled with the critical but ignored ancient bugs that alienate userbases of entire operating systems, is something that will turn any serious developer away from a programming language’s ecosystem.

I dislike Node. My dislike is based on negative experiences mainly revolving around npm. That might change in the future, but for now, I’m filled with dread and despair every time I have to use Node in any capacity. We all have our preferences, but it’s important to remain objective and pick the right tool for the job. But it’s also important to admit that sometimes picking the right tool entails picking the wrong one first because you just don’t know yet. So don’t listen to Craig. Don’t listen to Jim. Don’t listen to me. Try it out — see what works, find out what feels good and use that. Ultimately, the environment that makes you feel productive and awesome is the best one, not the one that gives you a millisecond shorter loading times.

James:

Node is hot. There is a whole lot of innovation going on right now in Nodeland. Whilst passion is subjective, I’m glad Node won this round.

Round 10: The Future

Round 10 looked at the future of both languages, and Craig declared this one a draw, as both languages look to have a strong future at this stage.

Bruno:

Bruno had to rush off to write some more PHP and edit incredible PHP articles for SitePoint.

James:

James was itching to get back to his beloved JavaScript channel, too, but offered these parting words:

A draw was a fair result for this round. Node is the rising star, but it’s going to take something massive to unseat PHP.

To wrap up, if your only tool is a hammer, then every problem looks like a nail. Node isn’t the perfect fit for every scenario, and indeed there are many times when it makes sense not to use it. However, what Node does well, it does very well. It’s up to you to make an informed choice and choose the best tool for the job.


So, now that Bruno and James have had their say, what do you have to say?

Frequently Asked Questions (FAQs) about PHP vs Node.js

What are the key differences between PHP and Node.js in terms of performance?

PHP and Node.js have different performance characteristics due to their underlying architecture. PHP is a synchronous language by default, meaning it executes one operation at a time, waiting for each to complete before moving on to the next. This can potentially slow down performance when dealing with heavy I/O operations. On the other hand, Node.js is built on JavaScript, which is asynchronous and non-blocking by nature. This means it can handle multiple operations simultaneously without waiting for one to complete before starting another, leading to potentially faster performance, especially in applications with heavy I/O operations.

How does the learning curve for PHP compare to Node.js?

PHP is generally considered easier to learn for beginners due to its straightforward syntax and wide range of online resources. Node.js, while not overly complex, does require a solid understanding of JavaScript and asynchronous programming, which can be challenging for beginners. However, if you’re already comfortable with JavaScript, you may find Node.js easier to pick up.

Which is more suitable for real-time applications, PHP or Node.js?

Node.js is typically more suitable for real-time applications such as chat applications, collaborative tools, or multiplayer games. This is due to its event-driven, non-blocking architecture which allows it to handle multiple concurrent connections with high throughput, which is crucial for real-time applications.

How do PHP and Node.js compare in terms of scalability?

Both PHP and Node.js can be scaled to support large applications, but they do so in different ways. PHP scales vertically, meaning you increase its capacity by adding more powerful hardware. Node.js, on the other hand, scales horizontally by adding more machines to your server pool. Node.js also has a built-in module, Cluster, that allows you to take advantage of multi-core systems to create child processes that all share server ports.

What are the differences in terms of community support for PHP and Node.js?

Both PHP and Node.js have large, active communities that contribute to their development and offer support. PHP, being older, has a vast amount of resources, libraries, and frameworks available. Node.js, while newer, has seen rapid growth and has the backing of large companies like Google and Microsoft. Both communities are active in developing and maintaining a wide range of open-source projects.

How do PHP and Node.js compare in terms of security?

Both PHP and Node.js have robust security features, but the security of an application often depends more on the developer’s knowledge and practices than the language itself. PHP has been around longer and has a larger user base, which means it has been exposed to more security threats and has developed more security features and best practices as a result. Node.js, being newer, has fewer known vulnerabilities but also fewer built-in security features.

Which is better for SEO, PHP or Node.js?

Both PHP and Node.js can be optimized for SEO. PHP has been used for many years to create dynamic websites that are easily indexed by search engines. Node.js, on the other hand, can be used to build fast, scalable applications that can improve user experience and site performance, both of which are important factors for SEO.

How do PHP and Node.js compare in terms of database support?

PHP has extensive support for a wide range of databases, including MySQL, PostgreSQL, and SQLite. It also supports NoSQL databases like MongoDB through third-party libraries. Node.js, on the other hand, is particularly well-suited for NoSQL databases like MongoDB due to its JSON-based data handling. It also supports relational databases through third-party modules.

Which is more suitable for server-side rendering, PHP or Node.js?

PHP was designed for server-side rendering and has been used for this purpose for many years. Node.js, on the other hand, can also perform server-side rendering, particularly when used with frameworks like Express.js. However, Node.js is often used for building APIs and back-end services, with the front-end handled by a separate technology.

How do PHP and Node.js compare in terms of development speed?

The development speed can vary depending on the complexity of the project and the developer’s familiarity with the language. PHP, with its straightforward syntax and wide range of built-in functions, can allow for rapid development. Node.js, with its event-driven architecture and non-blocking I/O, can also enable fast development, particularly for real-time applications or services with heavy I/O operations.

Bruno SkvorcBruno Skvorc
View Author

Bruno is a blockchain developer and technical educator at the Web3 Foundation, the foundation that's building the next generation of the free people's internet. He runs two newsletters you should subscribe to if you're interested in Web3.0: Dot Leap covers ecosystem and tech development of Web3, and NFT Review covers the evolution of the non-fungible token (digital collectibles) ecosystem inside this emerging new web. His current passion project is RMRK.app, the most advanced NFT system in the world, which allows NFTs to own other NFTs, NFTs to react to emotion, NFTs to be governed democratically, and NFTs to be multiple things at once.

James HibbardJames Hibbard
View Author

Network admin, freelance web developer and editor at SitePoint.

nodePHPRalphMreplysmackdown
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week