There’s no doubt PHP is the most known and commonly used language for server-side scripting. Before Django and Ruby on Rails gained popularity (200...
For further actions, you may consider blocking this person and/or reporting abuse
These are two separate worlds. I think it's a choice of habit.
I'm programming in PHP from 2003.
Then Rails. Then Node.JS.
All of them are differ. They can be used for the same purposes, but any of them has its own advantages and disadvantages.
No one will deny you to use any stack of technologies in your work.
And if you're not doing large scalable projects performance difference between those languages is not so noticeable.
So here are a few thoughts of mine using php/node for both web and non web projects.
For this I am assuming php 7+ and node 8+.
So for web I would give node.js the edge, and for an api only node.js for sure. In my experience node simply has better performance in both req/sec and, imo, more importantly response time. A caveat here is if you are doing heavy cpu processing (especially if you can use a php c extension), because php is typically faster in that regard.
So in my testing (not the most scientific method mind you) on my local linux vm using I was able to handle 40x more concurrent requests on node before degrading response time to over 200ms. I have played around with php-pm with a Symfony project and I was impressed with performance, but it would frequently error for no reason I could figure out.
Now I will say the frameworks for php are better (if you like using a framework). I think this has to do with how long php has been around and that people tend to contribute to fewer but very well maintained frameworks in php. Node has a metric crap ton of frameworks and they all seem to have some issues. PHP will also be easier to maintain, though typescript is making node easier.
Overall though if you are looking to make a website that is not internal use only then the performance difference is really hard to ignore. Especially since js is not all that much harder.
Not played around with Node that much, but I got the feeling, correct me if I'm wrong, PHP runs every request independently, so breaking code on one URL won't affect other visitors, while on Node project you could crash the whole service, and would need to restart it for the whole site/app to be available again?
You can make micro services with nodejs so that if one crashes, they don't all crash.
Both replies to the original comment are workarounds. PHP provides this out of the box, while with Node.js you need to create an architecture around handling such cases.
Basic error handling can prevent this from happening. It's native if you are using Express.
I had to do a comparison for a new startup actually and (unfortunatelly) I had to choose between these 2 languages, and putting aside the local market available developers, PHP really didn't brought any advantage on the table.
It may behave better with *SQL databases (I found this reason as stated by other devs, but I haven't seen any data on it), but rather then this NodeJS is better at ecosystem, latency, re usage of the code between frontend/backend, and a few others. I will have to search my paper on it.
But between NodeJS and compiled back end languages like Go,Rust and Java enterprise Apps I really don't see PHPs place in any med/large app/team in 2018 and beyond sorry. I think it is still popular because of the sheer amount of developers that know PHP.
Packages
I have not played with composer in 5yrs, but I bet is better than the NPM as a tool and as an ecosystem (which is a total mess).
No real project/customer that has more then 3$ monthly will use a shared hosting, so it is an invalid argument. For more serious hostings managed env nodeJS has more supported environments actually (including Cloud Functions).
Sure thing it is, is actually why Node will win in intensive web apps. Should I remember you that I/O include any DB and API query?
Even if PHP 7 is a lot better then the previous, let's just say that I trust V8 performance team more than I trust the PHP devs on the long run.
I cannot believe you mentioned CMS and Wordpress in the "Scalability" subtitle.
PHP-FPM is easier to scale then nodeJS that is for sure and well supported. For nodeJS a simple similar alternative would be single-core machines with auto-scaling LB.
There are hundreds of thousands of freelancers living acceptably comfortable lives by having dozens of clients who are willing to pay a few hundred dollars as-needed but unwilling to pay any kind of monthly fee. And even if they did, not everyone has the time to be an expert in all the areas of expertise they already dabble in and then have to learn to do their own devops on top of that. They'd rather pay monthly for real professionals to manage their server for them IF their clients really needed that, but most of their clients do not need it.
I'm a php fan but I have to disagree here. I've watched tutorials on using MySQL with Node and it seems just as easy as php.
I personally prefer PHP 7 to Node. Here is a cool video by the creator of PHP about the language: youtube.com/watch?v=rKXFgWP-2xQ
"For almost 10 years, it had been the only option for a back-end developer." You seem to forget ASP, JSP ... popular template engines for C# and Java.
I didn't understand the conclusion: who wins?
No one wins. There’s just your needs and the needs of your project and choosing a server-side language appropriately.
Just to add to this discussion, PHP 8 will be a true JIT compiled language.
Small correction:
You don't. They're included with Node.
I think there is a mistake, PHP means "Personal Home Page". It's a weirdly common mistake though, even the PHP docs seems to make it.
It was just called "personal home page" in very early versions. Ref en.wikipedia.org/wiki/PHP#PHP_3_and_4
plz look at link where I am use react and php
academia.edu/38021343/Pozivanje_ph...
I've used both PHP and Node.js, and I recommend both of them.
Helpful article, thank you for putting the time to write it.