NodeJS vs PHP fallacies

I recently had my attention directed towards this post by Phil Sturgeon. It’s about a year old now, but still very relevant.

I’m posting it here mainly to hear your opinions about the matter, and to let our community know of this “debunking of trollism”, so the next time someone decides to throw benchmarks at you in order to prove superiority of any language over any other language, you can refer him to Phil’s post.

Btw, if someone has some real world usage examples of ReactPHP they’d like to write about, I’m all ears.

It’s because PHP is the ugly duckling and everyone and their mother will find any excuse to bash it.

Ah, nodejs. I’ve learned quite a bit of it and came away with the same impression that a humorist on youtube wrote. To wit

All the complexity of assembly, with the efficiency of javascript.

I mean, seriously, JavaScript callbacks are powerful, but once you’re tracking enough of them it can become a very massive headache to deal with. I’ve written several largish JS apps using frameworks from prototype.js to angular, but resolving race condition bugs still leaves me with ulcers.

The article is spot on with the real complaints on PHP, many of which are listed on phpsadness.com, but JavaScript has more than a few “shining” moments of its own as seen on wtfjs.com

More than a few of these problems the two languages have are a result of a shared trait - their loose datatyping.

Anyway, I always get a chuckle about speed contests between interpreted languages since compiled languages such as C will always leave them in the dust. And if you really feel the need for speed, there’s assembly. The problem comes with the amount of developer time required. As a rule of thumb, your time is always worth more than the CPU’s, so trading some raw execution efficiency for ease of code writing, maintenance and comprehension is worth it.

And that’s my largest gripe with nodejs. The callbacks pattern is fine when in a shallow small application, but it can rapidly spaghettify, especially under time pressures. I’ll concede that some of this problem is me and would go away if I spent some time with it, but some of it is inherent to the language and the framework’s structure.

One large stumbling block with JS is the prototypical inheritance. It is incredibly powerful and allows for very rich code, but it is a considerable paradigm shift from classical inheritance and the similarities belie the differences between them. It takes awhile to make the jump and for awhile I found myself using prototypical inheritance to emulate classical, which sells the concept way short of what it’s capable of.

1 Like

There are ways around this without going that far. Java, Scala, and Go for instance are all that fast without needing to go directly to the hardware with C and ASM. There are frameworks that make writing web apps very easy and quick, a long ways from the early J2EE 16,000 line XML boilerplating.

I’ve seen several cases of Node.js outperforming Java/Scala in production due to the way it forces a certain style of architecture. How this relates to developer time I’m not sure, but it seems to have impressed those using it.

Here’s one. This is just the first one I found on Google. First time I’ve read this one specifically.

Here’s one comparing the performance.

This article is a strawman covered in a thick layer of PHP Fanboyism. Like most of his blog posts, tweets, and reddit posts.

Be language agnostic and look at things objectively. It’s the only way. I could probably show that Mars is bigger than Earth if I tried hard enough. It won’t necessarily be true or rock-solid, but neither is anything that comes from Phil Sturgeon.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.