Node.js is an open-source cross-platform JavaScript runtime environment enabling us to write server-side components using the JavaScript programming language. Based on Google’s V8 JavaScript Engine, it uses event-driven, non-blocking I/O model which is ideal for data-intensive real-time applications that run across distributed devices.
Thanks to JavaScript, the way web applications are built has dramatically changed in the recent past. It brings in lots of capabilities and advantages over other languages. And with Node.js, things have become easier and provide a minimalistic way of writing applications these days.
JavaScript is everywhere
JavaScript was created by Netscape meant for the internet and it’s been there since the very beginning. With Node.js, it is available on the server too. Attempts to bring in alternative client based technologies such as Java Applets, Microsoft Silverlight, Adobe Flash, etc. have gradually faded due to the complexities involved.
Non-blocking I/O model
In the blocking I/O model, while one line of code is executing, the rest of the code is locked waiting for the previous one to finish. In order to achieve concurrency, this model requires spawning of multiple threads to process concurrent requests in parallel. However, this comes at a cost of infrastructural and architectural upgrades.
For e.g., when you run the following Java program:

The program above generates output in the following sequence:
- Start
- Sleeps for 3 seconds
- I am here
- Sleep for 1 second
- End
On the other hand, the non-blocking I/O model gives each line of code a shot, and then through callbacks it can reappear when an event occurs.
For e.g., when you run the following JavaScript program:

The program above produces output in the following sequence:
- Start
- I am here
- End
- Timeout for 1 second
- Timeout for 3 seconds
If you’ve noticed, “Thread sleep” was actually simulated using the “set Timeout” function. Technically this is the callback function in JavaScript which is already executed by the interpreter, but it returns only after the specified timeout period is over. Traditionally, JavaScript was intended to be lightweight running faster on a browser, which itself is the single thread model. This is the reason why JavaScript is single thread and hence faster in execution.
Usage of JSON
JSON (JavaScript Object Notation) is a simple, lightweight data exchange format that has enabled JavaScript (and Backend) developers to exchange one standard format across layers, thereby making it interoperable and easy to use. JSON and JavaScript have reinforced each other's importance and are influential in the creation of document-oriented NoSQL databases such as MongoDB and CouchDB. Content stored in these databases is JSON in format.
Productivity
With JavaScript and Node.js, the gap that existed between UI developers and Backend developers has been broken down, which means merging frontend and backend developers into one team, thereby bringing lots of efficiency and transparency. Node.js also has a great package management system called NPM; it’s the first package system for JavaScript to get the dependency management right.
Community Support
The community behind JavaScript is quite vibrant and has penetrated almost all fields of technology: data visualization, client-side frameworks, server-side frameworks, databases, robotics, building tools, etc.
Business Cases where Node.js can be adapted:
Internet of Things
With JavaScript being omnipresent, it can be used for programming both endpoint device and web services using Node.js. Leveraging the capabilities of HTML5, JavaScript can also be used to develop UI applications that can run on any device.
Real-time / Streaming Services
Due to the non-blocking I/O model, Node.js is ideal for writing network and data intensive applications. Chats, Video Streaming (leveraging HTML5 streaming capability), and other Collaboration tools are basically two-way real-time based applications. Also, Node.js does support both WebSocket and Server Sent Event protocols, which is the ideal technology while implementing near real-time web applications.
Build APIs
One of the key characteristic of APIs is scalability. If your API is not I/O scalable, then it is creating bad user experience that might hurt the business. Yes, scaling issues can be addressed by means of horizontal scaling, but this comes at a cost and technical debt. Due to the non-blocking I/O model paradigm, it is great for building lightweight APIs that can handle I/O driven requests.
Development Aspects
It all depends on the type of applications you’re working on. There are frameworks meant for specific usage and one needs to study before adapting the same.
Node.js core ships with connectors and libraries such as HTTP, SSL, compression, filesystem access, and raw TCP/UDP, leveraging the capabilities of the server and resources it relies on. With NPM, it’s easy to include modules and the dependencies that are necessary to applications. The full list of packaged modules can be found https://npmjs.org/
To develop REST APIs
- Express
- Hapi.js
- Restify
- LoopBack
If you happen to develop enterprise web applications including UI, Server side and DB then, use MEAN stack, a free and open-source JavaScript stack that provides end-to-end capabilities starting from client to server to database. MEAN is an acronym for:
MongoDB
A leading open-source NoSQL database empowering businesses to be agile and scalable with both structured and unstructured data. It saves data in binary JSON format making it easier to pass data between client and server
Express
Lightweight and flexible Node.js based web based framework providing a robust set of features for building single and multi-page, and hybrid web applications
AngularJS
JavaScript based MVC framework to develop front-end applications. It allows extending HTML vocabulary by means of DOM manipulation that result in an environment that is extraordinarily expressive, readable, and quick to develop
NodeJS
Platform and runtime environment for rapid development of I/O scalable network applications.
One of the biggest advantages of using MEAN stack is that the programming language and data exchange format would remain same across architectural layers i.e., JavaScript and JSON respectively. With MEAN stack, one will have to invest time to understand the modules, and adaptability before usage. You can adapt the best suitable MEAN frameworks such as:
Any framework is good for development as it provides abstraction to underlying services reducing boilerplate code and allowing developers to concentrate on implementing the functional aspects alone. The end result is maintainable code.
Unit Testing Aspects
Multiple libraries are available for unit testing. Some follow the TDD approach and some BDD. It depends on the architectural decisions of projects. Below are some well- known unit testing frameworks:
- Mocha – Can be used for both TDD and BDD approach. Ideal for standalone services and REST APIs. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases
- Expresso – TDD framework written for Node.js. Expresso is extremely fast, and packed with features such as additional assertion methods, code coverage reporting, CI support, etc.
- PhantomJS – For Rich UI applications that does testing using headless browsers
Build and Deployment Strategy
Coming to deployment, challenges are multi-fold as it involves packaging, dependency management, single-step deploy and hosting without service interruption. With the wide adaption of JavaScript and Node.js, PaaS providers could not sit back and relax. Providers such as Amazon WS, Google App Engine, Heroku, Microsoft Azure, and others provide tools and capabilities for deployment of Node.js based applications.
Conclusion
Node.js has already seen wide adaption. Many of us have seen the traction in cloud adaptions at an enterprise level despite there being few concerns surrounding security, portability, adaptability, etc. Cloud Service providers were simultaneously working on probable solutions and service offerings by bringing in capabilities that met enterprise needs. However, with several advantages associated with using Node.js, I expect adaption by organizations to increase in future.
JavaScript is already a popular programming language (as per GitHub community). So is Node.js, AngularJS, MongoDB and other JS based frameworks. However, the emergence of JavaScript and Node.js at the server-side does not ring the death knell for popular programming languages such as Java, .Net, PHP, Ruby, and others. These languages have their own prominence and will stay for long.

