Oliverde8's blue Website

  • Home
  • Is Node.js really be better then PHP? A pointless discussion

Is Node.js really be better then PHP? A pointless discussion

Recently there has been lot's of articles about how great & superior node.js is vs PHP. 
So I decided it was time for me to give it a try. Of course I know that node.js isn't a language but more an integration of javascript as a server side scripting language. 


The main point that is pointed out is the speed thanks to it being non blocking. That quite bugged me. 

On the majority of the applications I have worked on Symfony, Magento(1&2) Drupal... The main reason the application takes times to open is the database. So Node.js will be faster because it's going to be able to do multiple queries at the same time. Until here all is looks fine.  

But what happens when you have a thousand users? The Database will slow down due to the number of queries, and because at one point Node.js or not you need to wait for the queries to finish the website will slow down. And at this point I don't understand how node.js helps. 

What node.js does is to better use your systems multiple cores to show a webpage to a user as fast as possible. It doesen't really help for delivering more pages, it's not a game changer. We can very well create clusters of PHP servers to handle a hight amount of traffic; but relational databases are going to be remain the strangling points. 


Well node.js is basically javascript, so it's not the nicest looking code; I actually prefer the syntax of php, where we have a more structured format.


Today PHP has a great ecosystem with great frameworks(symfony, laravel) It took years for these frameworks to come where they are today. The ecosytem of node.js is still in fluctuation. There are a lot of tools doing similar things but using completely different ways to do it. With time proper tools that are going to emerge enchance the strenghts of the language. But right now the language (more so the framework) being so youg there are to many fluctuations. 
What I mean by fluctuation, is that there is no standards yet, the proper way of doing things is still changing. So if you start with a big project today by the time you finish it you will need to start over again. This isn't the case with PHP where frameworks such as Symfony has sattled down.


We are comparing oranges with bananas. PHP will probably continue to do what it's doing, powering relatively big website with lot's of trafic & lot's of complicated code. 

Node.js on the other hand will grow in importance & I think will be used in very complex & cpu intensive applications that has a limited amount of visitors. For exemple if we wanted to do a website to create complicated statistics on the go for a big e-commerce website we would use node.js and plug it to one or more of the slave databases. The non blockingperation of node would allow to query mutliple databases for different data without having to bother about all the relations. 

I can even think on complex hybrid applications using both PHP & node.js. 

Node.js in another tool in our arsenal for web applications. There is nothing we couldn't do using other server side programing languages such as java. But nevertheless, node.js is much easier to use for doing applications requiring todo multiple long queries. PHP & node.js are both different tools, which each their own cons & pros. Intime some of our php applications might get redone in node.js because it simply makes sense; but I do not see a sucessor to PHP.


Categories :