5 ways how PHP is better than Node.js

Tags:

All hail Node.js! Boo PHP!

Except there are various things where PHP is better than Node…

Be sure to read the comments too for some discussion :)

Easier to find hosting

Majority of the web’s hosting providers are able to provide PHP hosting.

For Node, you need a much more specialized hosting provider. Typically you need shell access to set up your application, and most web hosting services do not include anything like this, or if they do, the other packages are much cheaper.

It’s easier to get started with PHP

With PHP, you can simply install WAMP, LAMP or MAMP and off you go. For deploying code into a web host, you just drop your files there and you’re done.

Although Node itself is not hard to install, it does require more specialized knowledge to set it up nicely. In order to install it on a server, you generally need some level of Linux sysadmin knowledge in order to set up the necessary packages, and tools such as process monitoring to keep your node instance running in case of a crash.

If your PHP code breaks, it doesn’t bring your whole server down

As PHP code runs each in its own process and the web server sits in front and directs this, if one of the requests causes an error it will only affect that specific request.

In a Node environment, you typically have a single process serve all the requests. If one request causes an uncaught error, the entire server comes down.

PHP processes are short lived

In PHP each process is only alive for the duration of the request. This means you don’t need to worry as much about resource allocation and memory.

In Node as the process is running for a long time, you need to be careful to manage memory properly. For example, it’s easy to accidentally take tons of memory if you forget to remove items from a global array. It’s also easy to accidentally write code which leaks memory. (which in turn can bring the whole process down again)

Bigger standard library

PHP’s standard library is much bigger than Node’s.

In closing

This is not to say that PHP is better in every way than Node. It’s simply to point out that while Node is very good at certain things (real time processing of messages for example), it is not a silver bullet for all problems.

Feel free to leave your thoughts in the comments, or if you can think of more ways where PHP is better than node.