PHP vs. Node.js: the Battle For Developer Mind Share
snydeq writes: Simplicity vs. closures, speed of coding vs. raw speed — InfoWorld's Peter Wayner takes a look at how PHP and Node.js stack up against each other. "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."
This would be the worst movie ever.
I actually RTFA and found it to be completely useless.
I'd have thought most people are just getting on with whatever the preferred toolset is at their company and never give this mythical war a second thought.
I want a list of atrocities done in your name - Recoil
... JavaScript must die. I expect TFA to concur.
(this is not a
That sounds more like a generation conflict between the college-smart son and his blue collar dad who often cuts corners.
It's all fine and dandy until you remember we're still stuck in a single thread.
Now cue the apologists.
But isn't it like comparing apples and oranges? PHP and Javascript do not have the same use cases...
Apples vs. Oranges: the Battle For Vegetable Mind Share
PHP is a carcass. Whom can deny the Angel of Death? What Shai-Joyent has decreed, shall be.
But seriously, PHP is a dying language. We should let their developers pass.
Rusty-trusty old school, or new age faggotry?
These two languages each have their own use, and to chose between them you should not ask which is better but which is closer to my use case.
PHP, for all its problems, is still a very useful language for developing web sites, if only for the quantity of tools (frameworks, cmss, etc) available and their quality (far from every php tool is good, but you can easily fond a quality tool for each category: symfony 2 is a very good oo framework, drupal and ez publish are good cms...).
Node is younger, and does not have such a toolset. Sailsjs is a good framework but far from mature.
But it does what php can’t: a nodejs application is its own server and runs continuously, instead of being a set of scripts that must reload everything with each request.
It makes it a very good language for real-time uses, like the back-end of a small multiplayer game.
TFA is ... okay (I must be new here) but has a few forehead slappers. Quotes include:
"They were built by programmers who understand that modern Web apps should push most of the intelligence to the client."
Headline: "Where Node wins: Service calls are thinner than HTML-fat PHP calls" (uh, yeah see, that's the whole point of javascript on the client, it's called AJAX) Body: "While AJAX-crazy HTML5 Web apps can have too many moving parts, they are cool -- and very efficient." (What, AJAX is Node-only?) Conclusion of the same paragraph: "If your app is complex and data-rich, it's a good foundation for efficient delivery." (a good foundation? really?)
"Writing JavaScript code is a bit harder when you're counting curly brackets and parentheses" (...)
(... sorry still bogging, parens are haaaaaard?)
(yup still boggling, but haven't missed a closing paren yet, and there's no rainbow feature in /., though I sense a webmonkey script...)
Awesome captcha, 'befuddle'!
PHP is far more available in cheap hosting solutions. The apps are simpler to deploy (simply put them along your static html files in a web server that supports its extension), and simple apps are simpler in php. The ecosystem around was not touched in the review, Compose vs npm, joyent vs the community behind php, the future of both platforms.
In the other hand, PHP is (or at least, used to be recently enough) a fractal of bad design
php&node
Man I've read articles where the author didn't know what they were talking about and was just stacking points, but they're made here with such assertiveness and surety that I started doubting reality. +1 great trip, no mushrooms required.
... and you should feel bad
Proper systems and apps developers wouldn't touch either of these noddy languages with a sterilised bargepole.
This isn't merely useless, nor just bad, it's completely misleading. For it may look like he's giving the high-level, the author appears to have no depth to draw on to say more than the shallowest things. As such, he's presenting pond scum, not the high points from an expert deep sea fisher.
And this is pretty bad, given that infoworld says about themselves:
while the TFA says about the author:
I'm loath to seek out his writing, in fact fairly convinced to stay well away, while at the same time morbidly curious just how bad his "more than 16 books" will misinform.
PHP, the meth-addled brother you remember from childhood that occasionally wants to have lunch, if only to waste enormous amounts of your time. He still doesnt quite work consistently, his habits get expensive, and everyone remembers that one time he just sat in a corner screaming 'true == false!! false == TRUE!!!!' until someone called the devops.
and Node.js, the kindhearted strapping beaux from the small town with a heart of gold, even if you didnt always understand his quaint allegories. These days hes become an insufferable jackoff in a suit and tie who's managed to alienate all but a few close friends who from all indications are complete douchebags. Everyone talks about his brother io.js, though. maybe that kid's worth an email.
Good people go to bed earlier.
Looks like keeping mindshare is an uphill battle.
TFA is a bunch of blabbering from someone who has no idea what he's talking about - void of anything useful.
To get this out of the way:
Node.js is a serious contender to topple PHP off the server-side, for the simple fact that we would then have one PL less in the entire webstack, which is way to
complex anyway.
I myself have been pondering trying out Node for larger non-trivial projects. I'd be the first to switch if it were possible.
I haven't yet - Node is just not quite ready for prime-time.
Why?
1.) The tools don't exist yet and Node seems to gather the same problems Rails has: A bloated, instable and unreliable mumbo-jumbo of countless libs, tools and extensions - various package managers included, each built on a whim and powered by a neat logo and a 6-week fad that sweeps the community and adds to the mess already there. In short: The Rails problem of to much navel-gazing and not enough of solving real world problems.
2.) Callback hell.
In fact, its Node/JavaScripts callback hell that made me realise a thing that is so great about PHP: What you see is what has been made, for you, for that specific request. LAMP is such a bizar solution no one in his right mind would suspect it could work, yet most site on the internet run on it. The stack is so vertical it actually makes any Java solution look like an ADHD driven Visual Basic School projekt in comparsion. And I mean vertical right down to the way it actually works!
Try building anything like Joomla or Wordpress with other solutions such as JS and you'll end up with problems that completely leave the domain of your work. The simple fact that a PHP request is dead and gone when its finished sending its request reply and all the rest it offers is custom built around any strange problem the
Any concern you have right at the moment when developing for ther server side web PHP has neatly covered ... ok, forget I said neatly, ... but covered and everything else is put aside. PHP is born out of a template engine, and as bizar as it sounds, that's its advantage. Any problem the Web domain can come up with puts PHP in a very strong position. Serverside things PHP just shrugs of with some strange custom internal function has JS and Ruby tripping and falling flat on their face with no chance for rescue.
3.) PHP is 10 years ahead of the game. No joke.
Try finding a product like Typo3 or Wordpress in Java, Node, Rails or any other backend runtime you fancy. Won't happen. It take me 5 minutes to download Typo3, 2 hours to set up - mostly because configging Apache and setting up T3 is an arcane science unto itself - but then it's there. Everything I would ever want for a web product.
Joomla, Drupal, Wordpress and co. are even way easyer. The only other contender holding up is Pythons Zope/Plone. All else is a decade behind at least. Rails included.
Bottom line:
As soon as Node gets their shit sorted out and offers a serious upside vis-a-vis LAMP, PHP is going to continue to rule. It gets the job done. Node and Rails don't. End of Story.
We suffer more in our imagination than in reality. - Seneca
I come from a C/C++ embedded systems background but have done a lot of JavaScript recently and really find it to be the C of high level languages. For example:
1. Both C and JavaScript have a very simple and reasonably orthogonal set of basic constructs.
2. Pointers and first class functions are really the keys to the expressive power of each language. Both concepts take a bit of work to get your head around.
3. Neither language enforces much structure to your programs. This makes it easy to bash out a program (in both cases by abusing the global namespace), but much much harder to write high quality maintainable code.
But to many people (myself included) once you start to master this power, you really begin to enjoy the expressiveness of the language.
On the other hand, PHP is a bit so-so. It does its job, but doesn't really offer anything new or innovative language wise. It's main PR problem comes from the early days when it had some annoying design mistakes but these are mostly fixed now.
Also, the term 'JavaScript' means many different things to different people, and it is hard to tell how much of the flamewar come from people who think the $ sign is a reserved word.
Developer for last 15 years.. and I couldn't care less.
I let you children play with web scripting, and I go and do my buessnies in the high transaction, high scalability and low latency domain.
Have fun, with Node.js and PHP.. or whatever :-P
PHP will be around for a long time because any idiot (and I mean that) can have a go. That doesn't mean all PHP code is crap but what makes code 'good' can be skipped. (YMMV for what the base for quality code is.)
Come on? Stable? Can do good development in PHP!? Are you out of your mind? If you are fan of OOP in PHP, and OOP style can be implemented in PHP it doesn't mean it is better than JS or even god forbit equal to Java or C# !! Have you ever seen source code of common PHP applications like WordPress and SugarCRM or VTiger CRM ??? Now ask your self simple question, can you as developer who codes in OOP style, extend or implement new functionality to those open source projects!? Do you find appealing to that PHP code style (WordPress and so on) ? Because majority of job contractors are asking from you to extend thoese PHP code monstrosities, Ergo, PHP is something to be completly avoided if you cannot extend major PHP applications.
Those articles are generally stupid, but this must be the most stupid comparison i've ever read. No numbers, just hunches.
Php - 78% of all php apps on the web are runnnig with known security issues. http://blog.ircmaxell.com/2014...
Javascript on a server? The only JS I've seen looked like crap.
Better to choose perl, python, ruby.
The only worse language would be java.
Developers dont matter if their deployments crash and burn due to library bugs before they reach first year deployment, and that is a big part of the reason the new frameworks aren't taking over the world just yet, nobody wants of have a fragile platform that need expensive devops to run for things that aren't designed to be replaced/extended every six months.
And to make it worse there is no attention given to this problem in any of the fad2.0 communities, ie nobody really wants to build the new standardized LAMP stack but wants to have a configurable stacks that each app developer can freely modify. Because they are mostly freshly minted CS grads and not paranoid veteran admins who have been through the hell created with you got custom dependencies, and library vulnerabilities are found.
Neither node or PHP apps are known for their high standard of security hardening, and nobody wants to deal with frameworks that are, because they tend to be alphabet soups of design by committee standards and associated mess, so in the end the platform with the least customizable run time is chosen because then at least you can make sure the libraries gets security patches.
In my opinion the Python framework Django is the best web development framework out there.
PHP's popularity is largely the result of inertia in the industry. Lots of code bases are written in it so lots of jobs specify PHP. Almost no-one with any experience will recommend PHP for a non-trivial project.
Node.js doesn't have the tools and IDE support to be a great server side language. Besides......the only reason to write javascript is to execute code in the browser on the client side. If you're not doing that don't use javascript.
Not sure about rails..........never used it.
replaced with another shirty language. This like arguing which is worse: bull shit or horse shit -- guess what, they both stink.
This isn't a battle - they both suck. A developer uses whatever crappy web language there is to get the job done.
News at 11.
PHP - Writing in this still?
that io.org back in the 1990's when it was born - it was a copy of Perl - it has changed certainly to its own.
NPM makes php dead.
PS i was there for the birth of php - I was at io.org - node wins - I have used both and refuse to use PHP anymore.
I still use Mason.
An obvious neither-nor decision.
I'll stick to C#.
Thats a weird comparison, since they don't target the same audience at all. Rails maybe, as it has a lot in common, but even then.
What makes node interesting is that its asynchronous-first, single-threaded-by-default model has interesting performance characteristic and lends itself well to specific architectures. Bonus that it also works amazingly well for web sockets. There's also a lesser point that still matters, its JavaScript and some people like that a lot.
The tradeoffs however are pretty massive. There's a lot less literature on how to maintain a node production environment. How do you handle memory dumps, how do you instrument it. Also, error handling is terrible, and debugging obscure issues is hell. There's a lot of minor bugs and quirks that you just have to "know".
That makes node.js only really suitable for fairly advanced developers/sysadmins (even if you host it "in the cloud"). Those that have "gone around" and have dealt with shit enough they'll know what to do when that shit happens, even if they can't find the answer on stack overflow. They also benefit from the interesting performance characteristics I described above.
On the other hand, PHP was always a "easy to pick up and run, forget about it" environment.
Those 2 couldn't be further apart.
I find php to be one of the nicer to use languages
When did PHP stop being "a fractal of bad design", as a well-known essay claims? True, not all points in that essay are valid, but I myself see six categories of valid criticism of PHP.
What, AJAX is Node-only?
It is if you want to share validation logic between the client (which on the web must be written in JavaScript or a language that compiles to JavaScript) and the server. If the validation logic in both environments is provably identical, you can validate on the client for instant feedback and then revalidate on the server for security, and there will be no confusing or insecure inconsistencies between the two. Otherwise, you have to translate from one to the other, and manual translation is fraught with potential for defects.
Can't someone seeking hosting just get an $8/mo WebFaction account and set up PHP and Node sites under it, or get a $10/mo VPS and deploy whatever the expletive he wants?
Cancer versus AIDS. Which to choose. decisions decisions decisions.
Excuse the Unicode crap in my posts. That's an apostrophe, and slashdot is busted.
How long will these VMs remain affordable as more and more web site operators switch from shared hosting plans to VMs that need their own IPv4 address?
So...do any of the PHP bashers do any actual extensive coding in PHP? Have you ever looked at the code in Drupal 7/8?
Seriously, I am always baffled by everyone who starts ranting on how crappy PHP is. I have done mostly PHP development for 12+ years. I have yet to have a site hacked, or SQL injection exploited. It is a very solid language, it can be made VERY fast (JIT is also coming down the pipe out of the box in 6+). It lends itself to rapid prototyping and easy patching / testing. There is a module / plugin / snippet of code out there for pretty much everything. It will run on a windows server, a debian box, and CentOS pretty much the same.
Loose variable typing is not always bad thing, and you can always cast variables anyway:
$_GET['my_var'] = (int) $_GET['my_var'];
Ta-da! We definitely have an integer now!
I have written entire chat bots with raw socket connections in PHP...it can pretty much do everything...and do it quickly.
neorush
The correct answers are: If you want a slow easy language, use python. If you want a fast hard language, use C. If you want a fast easy language, then you will have to be an expert in the field for which you are programming, and you should use the field's domain specific language, in which you must also be an expert.
"who understand that modern Web apps should push most of the intelligence to the client"
you are seriously out of your unholy god fucking mind. in this office you would be hung over your desk till you pee on the monitor and then fired.
The piles of money we saved in support by bringing the processing back onto the server and STOP trying to get every device and every different browser to manage the same dom the same way...
nope never going back there
Just write it in C++ with TDD, which will run faster, and after you factor in all the pain from debugging server side untyped dynamic languages, will also be faster to develop.
Let the flaming commence.
Easy Online Role Playing Campaign Management
Have you ever seen source code of common PHP applications like WordPress and SugarCRM or VTiger CRM ??? Now ask your self simple question, can you as developer who codes in OOP style, extend or implement new functionality to those open source projects!?
That would be a yes, to both questions.
As a matter of fact, I just finished writing a custom shipping cost calculation system for a Drupal Commerce site. One file with a small amount of procedural code (two hooks and a handful of two-line callbacks) to glues my OOP code to Drupal. Everything beyond that is neat and clean. I've used similar approaches for any number of custom extensions.
Let me ask a counter question. Have you not seen mediocre developers write absolute crap in Java/C#/whatever-your-ideal-language-is? I won't argue that all languages are equivalent - some are better than others - but most of the major ones can either be used well or poorly. I haven't come across an idiot-proof one yet. Seems to me there's a lot of blaming the tool for the faults of the craftsman around here.
"But then some clever kid discovered he could get JavaScript running on the server. "
Really clever kid. We had this in 1994.
well you just tried to get programming knowledge from a magazine specialized in paid reviews of software and hardware.
what did you really expected? honestly.
also, this is a new low even for slash dot editors standards.
first let's get a better GUI standard than browser-based DOM. Customers want desktop-like UI's on the web, and HTML/CSS/JS/DOM has to be force-bent under threat to pull it off, and still broken or jittery half the time even on big-name deep-pocket sites.
Sure, it's job security, but at the expense of turning grey prematurely.
The programming language choice would matter less if the programming language didn't have to do so much to deliver GUI's.
Table-ized A.I.
I got more out of the comments on this thread than I did out of that POS, hack of an article and I've used both languages on a daily basis for two years. Thanks /.
But 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.
What is this blogspam shit doing here? There's no "need" to use either of them, there have been loads of alternatives to PHP for years and there are still plenty of alternatives for both. The individual points make no sense either, it's like they've just quickly Googled for "PHP advantages" and "Node.JS advantages", bullet-pointed them on a page and stuffed the rest full of ad links.
Charlton Heston? I mean if he was still alive, not that PHP is still alive.
“Common sense is not so common.” — Voltaire
use of php is monstrous compared to the smattering of node.js shops out there
That is the question.
Whether 'tis nobler in the framework to suffer the slings and arrows of outrageous edge cases,
Or to take up code against a sea of requirements, and by opposing end them?
Personally, I prefer the basic PHP (and JSP) model of just writing out a web page with your backend language. I guess that makes me old-school?
(T>t && O(n)--) == sqrt(666)
I develop web applications for a living, and just don't give a crap about what any language does. It's completely personal preference or whatever you're stuck with. I'm really tired of stupid folks, of my generation, writing crap about X vs Y. It's stupid and shows how little you know about programming.
"Derp. Javascript is async, it means it's faster and better?!?!?!?!?!!!!!!"
Hate javascript? Who fucking cares? No one.
"Derp. PHP is fast and everyone knows/uses it!?!?!?!?!!!!!!"
Hate PHP? Who fucking cares? No one.
I don't like either, but it doesn't fucking matter as either work. In general both are pretty pathetic and lack serious features, or thought, so it's sort of a race to the bottom. Anything where I don't have to manage my own memory is good enough for a web application. Can't scale your app with "x-language" it's because you're a fucking idiot or you're a fucking idiot using the wrong tool for the job. "Why doesn't this hammer turn on my TV?"
I wish I could remember the days when people were actually solving problems instead of re-inventing a fucking event loop or UI programming paradigms.
It's fucking sad state of affairs we engineers live in...
They both suck, use java!
has never been taken seriously by anyone with half a brain.
Come on really? Just use Haxe and you can get either of these "outputs". Bah. PHP vs Node :P
emscripten and asm.js are ALREADY not cross platform.
Not all features work on big endian CPUs, so some asm.js websites do NOT work on firefox on solaris on sparc, but do on firefox on solaris on x86, for example.
You have used both daily for two years and hadn't yet figured out both are horrible?
http://blog.ircmaxell.com/2014... - written by a php developer. 78% of php running websites have known security issues.
Failure, regardless of why.
This reminds me of the time back in 2003 when I was working for a company developing an online casino.
The company ran on a complete MS stack and I was violently terrified of having to code in VisualBasic on IIS.
So I was completely overjoyed and excited to learn that IIS also supported MS javascript as well.
So I wrote all of the backend code in JS with all of it's prototyping goodness.
Of course MS javascript had lots of problems with the core prototypes (like string) not being extendable but I worked around that.
I followed Douglas Crockford postings with a religious fervor back then because he was the goto source for decent JS coding syntax.
Most everything he wrote worked on both IE6.0 and mozilla.
Of course I left the company (I found a much better job) but after a couple of years, they wanted me back as a consultant to help port the backend over to C#.
JS was too confusing for the new developers!!
Personally, I think what Branden Eich did with JS was brillant and very advanced.
Cheers
Ben
I am surprised he wrote this article, as he wrote another piece stating that Javascript for everything is the future of programming. http://www.infoworld.com/artic...