Node.js is a platform built on Chrome’s JavaScript runtime that untangles concurrency by replacing the Java platform’s standard, multi-threaded approach with single-threaded, event-driven I/O.
Node.js is a divisive topic in the programming world: it would seem that for each enthusiastic supporter praising its advantages, there is a vocal counterpart highlighting its shortcomings, or at least his personal disapproval of all the hype that’s been recently surrounding this technology.
What is indisputable, though, is the increasing trend in interest for Node.js – in terms of market share, open jobs or google searches. Here’s also an overview of well-known brands that use Node.js:
Image source: https://apmblog.dynatrace.com/2015/04/09/node-js-is-hitting-the-big-time-in-enterprise-markets/
So, it’s worth taking a closer look at the potential benefits that can be derived from Node.js. It’s not so much a question of ‘is it as good as they say or not?’, but a question of ‘which use cases benefit the most from it and when is it not such a good idea?’
1. Light-weight REST / JSON APIs – thanks to the use of JavaScript and the non-blocking I/O model, Node.js is a good option for wrapping other data sources such as databases or web services and exposing them through a JSON interface.
2. Real-time applications – Node.js is a great choice for real-time data-intensive web apps as well as soft real-time systems, like social networks, instant messaging networks or chat software. You can use it to build web-connected apps that gather data from different sources, consolidate it and push it to a great number of clients in real-time, as it provides an easily deployable migration layer that either proxies data to existing systems or collects and reformats data for different uses – this is why Node.js works great as a bridging technology for existing systems.
Node.js as bridging technology – image source: https://apmblog.dynatrace.com/2015/04/09/node-js-is-hitting-the-big-time-in-enterprise-markets/
3. Single page applications – because Node.js enables the processing of many requests / second with low response time and because of the fast synchronization between client and server, it works really well for web apps that do a lot of processing on the client, like AJAX heavy single page applications.
4. Command line utilities – js’ ability to spawn thousands of child processes and treat their outputs as a stream makes it a great choice for writing command line scripts and running shell commands to UNIX tools.
5. Programming hardware – there are several reasons why Node.js works well for embedded devices and robotics: it’s event driven, standardized and it supports IoT-specific communication systems, like MQTT, which is designed for fast status updates from small devices. It has a high productivity and by using JavaScript, it allows developers to implement many features in a short time, to build a prototype rapidly, get feedback from users and iterate. The IoT community has already embraced Node.js for, with notable examples including Nodebots and Cylon.
These are just a few examples of how Node’s capabilities can be best put to work.