What is Node.js?
BENEFITS OF THE PLATFORM
In order to adequately evaluate the benefits of the Node.js platform, we must evaluate the platform itself. Node.js is a specialized tool for managing I/O across file systems and networks in much the same way that SASS is a specialized tool for making color a variable in your CSS.
Non-blocking I/O: While it doesn’t make I/O operations any faster, this feature does ensure that I/O operations won’t interfere with each other. This means that the server can handle multiple requests at once without bogging down the Node server.
Event-driven: This means that you don’t have to rely on the client to make regular interval requests, limiting useless communication between the server and client. More specifically,
Low latency: The response latency of a modern web application has become one of the most important factors in determining a user’s experience. Node.js is able to quickly respond to connections in an efficient manner, making it very useful in designing real-time, mobile web apps.
Scalable: The manner in which Node.js handles concurrent connections makes it highly scalable. The server can handle as many or as few connections as is required of it without weighing down the Node server.
The platform also features numerous useful modules, saving you the trouble of having to write everything yourself. This, in turn, means that Node.js is really more than one thing: it’s a runtime environment, but it’s also a library.
DRAWBACKS OF THE PLATFORM
While Node’s unique design is powerful and elegant, there are also a few drawbacks.
“CLEARLY, NODE ISN’T THE SOLUTION TO EVERY PROBLEM. IT’S OBVIOUS THAT BUSINESS LOGIC PROCESSING WITH LOTS OF DATABASE CRUD, IMAGE PROCESSING, OR ANY LONG-RUNNING BLOCKING OPERATIONS ARE BEST AVOIDED.” — NODE 101 GITHUB FAQ
Beyond the various functionalities that are beyond Node.js’s scope of specialization, there are a few drawbacks that can typically be addressed by the developer. Among the most notable of these drawbacks are control flow, error handling, backend instability, and debugging chaos related issues.
Control Flow: The callback pattern is a powerful approach to asynchrony, however it can cause many issues for the developer – “callback hell” is among the unfortunate side-effects. Node.js supports other control flow patterns that can address this concern, for the most part. The other control flow patterns include events, streams, async modules, promises, and coroutines, to name a few.
Error handling: Each node process is responsible for a huge number of connections, so any unhandled errors could interrupt a large number of connections at once, as opposed to interrupting only the connection experiencing the error. This can be largely mitigated by handling all errors.
Back End instability: Due to Node’s asynchronous handling of incoming requests, high-traffic situations can contribute to backend instability. As more and more incoming requests become delegated to the worker thread pool, the backend can become saturated with too many requests.
Debugging chaos: Due to the relative immaturity of the platform, Node.js almost completely lacks any native debugging tools. Fortunately, tools like node-inspector, DTrace, and V8’s debugger exist to make debugging less of a nightmare.