Why and when to use Node.js? [duplicate]

It’s evented asynchronous non-blocking I/O build ontop of V8.

So we have all the performance gain of V8 which is the Google JavaScript interpreter. Since the JavaScript performance race hasn’t ended yet, you can expect Google to constantly update performance on V8 (for free).

We have non-blocking I/O which is simply the correct way to do I/O. This is based on an event loop and using asynchronous callbacks for your I/O.

It gives you useful tools like creating a HTTP server, creating a TCP server, handling file I/O.

It’s a low level highly performant platform for doing any kind of I/O without having to write the entire thing in C from scratch. And it scales very well due to the non-blocking I/O.

So you want to use Node.js if you want to write highly scaling and efficient applications using non-blocking I/O whilst still having a high level scripting language available. If needed, you can hand optimise parts of your code by writing extensions in C.

There are plenty of OS libraries for Node.js that will give you abstractions, like Express.js and now.

You don’t want to use Node.js if you want (slow) high level abstractions to do everything for you. You don’t want to use Node.js if you want RAD. You don’t want to use Node.js if you can’t afford to trust a young platform, either due to having to write large pieces of code yourself to do things that are build into other frameworks or because you can’t use Node.js, because the API isn’t stable yet or it’s a sub 1.0 release.

Leave a Comment