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
It's all fine and dandy until you remember we're still stuck in a single thread.
Now cue the apologists.
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.
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
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.
WFT X 2 the Battle For FRUIT Mind Share
Time for bed, said Zebedee - boing
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.
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.
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.)
Those articles are generally stupid, but this must be the most stupid comparison i've ever read. No numbers, just hunches.
"Where Node wins: Service calls are thinner than HTML-fat PHP calls"
Now I understand why browsing the web became impossible on my cellphone in 2014. Displaying a page is no longer about html + css. Now it's a stub page which needs a dozen more ajax calls before anything gets displayed. And good luck reading the article through the tangled mess if one of them doesn't get loaded. Oh well, it's just the current phase in the 10-year thin client sucks/thick client sucks cyclic history repeating itself.
Black Friday '14: E-commerce Pages Far Slower Than They Were in 2013 - Slashdot
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.
I still use Mason.
I'm sure that's how you use Note.js, but as far as I can tell, the vast majority of the usage of Node.js is server side. And that's where it overlaps with PHP. They both can be used to do the same thing, but with different strengths. For example, if you're building a modern AJAX app, Node.js is very nice - it's very efficient, lets you use the same programming language for the client-side and server-side code, uses JSON to pass data, is event-driven, good at web services, etc. PHP's strengths are more for the old-school, non-AJAX web sites - it's easy to stick a database query into a web page to pull data and display it, etc. And, of course, there's an already-written PHP solution for almost everything which is it's real strength. For example, if you need a web site CMS, you pick one, and if it's written in PHP (most are) then you use PHP to write whatever plugins you need.
Enable 3D printed prosthetics!
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.
But seriously, PHP is a dying language. We should let their developers pass.
No no no, you did that wrong!
Kosh: It is a dying language. We should let it pass.
Sheridan: PHP, or Node.js?
Kosh: Yes.
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.
No, he's right. The vast, vast majority of node.js use is as a glorified scripting environment as a build system for static resources. Its its gateway drug in a way. People use LESS to minify their javascript or something in their language of choice's assets pipeline. Then they go "Hmm, what if we used a real build environment for these?". Then they start using node in their build system. There's also stuff like Atom and all the node-webkit applications that use it as desktop apps. Those are the common usages.
Then sometimes, they go "Hmm, node is pretty cool, maybe we should use it for this micro-service in parallel with our existing stack". And then maybe, just maybe, it ends up on the server. Its pretty popular lately, but the percentage of people who use it as a web server is far and few in between, though growing.
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?
There are many frameworks that are still developed which make PHP useable and elegant...Phalcon for instance.
I object to power without constructive purpose. --Spock
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
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
PHP's strengths are more for the old-school, non-AJAX web sites
PHP's not bad at encoding JSON either. What else do you need to make it "AJAX-friendly?" (nevermind that the X in AJAX still technically stands for XML - not that that would be useful).
Oh well, it's just the current phase in the 10-year thin client sucks/thick client sucks cyclic history repeating itself.
No...this is a new phase. The "It takes a fat client just to run the thin client" phase.
"But then some clever kid discovered he could get JavaScript running on the server. "
Really clever kid. We had this in 1994.
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.
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.
Yes, PHP is easy to write, therefore it is easy to write badly. WordPress is the poster child for PHP's bad reputation, because:
Granted, PHP is the only language where a result like WP is possible. Shitty code hyped by an army of self-described "developers" who proudly and incestuously pass around bad practices like STDs.
That being said, JavaScript outside the browser is a convenient, unnecessary solution looking for a problem.
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)
That sounds more like a generation conflict between the fad-riding hipster son and his blue collar dad who often cuts corners.
FTFY.
"What do you despise? By this are you truly known." --Princess Irulan, Manual of Muad'Dib
/)
When did PHP stop being "a fractal of bad design"
It never was. That site is laughably bad. Most people puzzled that out years ago. It's time to let it go.
Required reading for internet skeptics
Come on really? Just use Haxe and you can get either of these "outputs". Bah. PHP vs Node :P
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
in the high transaction, high scalability and low latency domain.
So, bank robbing?
Ezekiel 23:20
So one person thinks the "fractal" essay is idiotic and another thinks the "hardly" one is. What opinion do you have of the six points?
PHP is the P in LAMP...
To me, the reason that LAMP must die is more the "M" part... MySQL. Given that somebody can't perceive the flaws in PHP it may not be any surprise that they fail to see what is wrong with the massive travesty called MySQL (see: ACID violation). Not that JS is an admirable improvement over PHP by any means, but if at least it helps wean masses of frontline weanies off of MySQL then it serves a worthwhile purpose. BTW, Postgres now gets lots of design wins in MEAN stack projects for (the many) cases where full relational db support is actually needed, or faster to bring up than a hand rolled MongoDB effort.
When all you have is a hammer, every problem starts to look like a thumb.
PHP is a carcass...
That is a wild exaggeration. Though personally I would like it to just die, the most you can say at the moment is that its exponential growth phase is over, and thus is rapidly losing share to other platforms that are still growing exponentially. It served its purpose and continues to carry much of the workload on the web but its glory days are over. Thankfully.
When all you have is a hammer, every problem starts to look like a thumb.
My opinion is irrelevant. An objective analysis of the claims made in each article should be sufficient for you to determine their quality. I seem to recall suggesting that you do exactly that, though I suspect that you haven't yet.
Required reading for internet skeptics
The six points I listed were the results of my having done that.
Overall language issues PHP is number 6 in this list...
http://www.aabri.com/manuscrip...
In terms of web apps, PHP looks pretty damn good by comparison:
http://info.whitehatsec.com/rs...
neorush
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...
important question:
does node.js work on WinCE clients? I know php does, I'm editing on my wiki via a Dell Axim X5 right now.
Political debates have me rolling my eyes so much I think I got optical whiplash. I should sue. - Foamy The Squirrel