What are Node.js and Basics of Node.js?

Node.js is fundamentally a server-side platform which has been designed using the JavaScript engine of Google Chrome. This is one of the most viral & frequently used frameworks by the developer community in implementing & deploying scalable network applications. The key characteristics of Node.js is that it employs an ‘event driven’ and ‘non-blocking input/output model’ which enhances the performance and efficiency of the application & makes it extremely agile and lightweight. To add to it, Node.js is an open source platform; and is compatible with all operating systems supporting JavaScript.

The subsequent sections would deliberate on the key features and concepts related to Noje.js; and the key use-cases wherein Node.js could prove beneficial for developers.

Basic features of Node.js

The basic features of Node.js which makes it the preferred choice for developers to build lean and scalable applications are cited below –

Node.js follows asynchronous method of data interchange or communication; which means that the application programming interfaces (APIs) do not get invoked in a sequential manner. Rather, the server calls the subsequent APIs at the same time; while having a notification mechanism to track previous APIs results 🡪 promotes multi-tasking to a great extent

Node.js follows a single-threaded architecture wherein the single thread is not attributed to a single program. Rather, Node.js uses an event looping concept wherein the single thread can actually enable the server to cater to multiple programs at the same time. This is an enhancement over the traditional or conventional HTTP servers which can accommodate limited number of requests at a time.

Node.js as a standalone application

The key difference between Node.js and JavaScript is that a JavaScript application runs on browsers and cannot be used as a standalone application as there’s no dedicated virtual machine. Node.js is an extension of JavaScript wherein it can be used to execute standalone and fully-fledged application on machines. A simplistic analogy of Node.js and Java is shown in the figure below.

As clearly shown in the figure; Node.js has a dedicated V8 engine which can execute commands; and multiple APIs which can be called for implementing different functionalities.

Different components of Node.js

As Node.js forms a comprehensive framework for application development and execution; hence, there are certain inbuilt components in Node.js which facilitates the end to end processing. The different components are mentioned in the figure below.

Now, each of the above components have different functionalities; and complement each other in execution of the application. A few of the components are described in the section below –

Call-back — An important component which facilitates the feature of event-looping which ensures that Node.js is able to asynchronous execute using a single-threaded architecture

Cluster — This component helps in creating child processes so as to enable multiple processes running on the same server. This component promotes multi-tasking to a great extent

Crypto — This component presents a wrapper class which provides valuable cryptographical features to applications. The component is mostly used in ciphering & deciphering texts or communication in a secured line.

DNS — A common component for most of the internet frameworks wherein it enables the server lookup functionality. The network wrapper enables in catering to all network resolutions

Error handling — Also termed as exception handling, this component is used to address possible compile-time or runtime errors which may be present in the application. This component is more so important as Node.js follows an asynchronous mode of operations; therefore, it may turn to be extremely challenging to accurately identify the precise source of the error (if not handled properly).

Key usages & non-usages of Node.js

The Node.js framework by virtue of it being lean and fast; can be used in a number of possible use-cases; a few of which are mentioned below –

Input/output applications — as the interaction is asynchronous in nature

Streaming of data — as Node.js deals in data with chunks; and do not buffer data

Single pager applications (including mobile application)

Designing APIs for transmitting JSON data

On the other hand, developers generally are averse to using Node.js frameworks for applications which are heavy weight i.e. requires high levels of CPU utilizations.

Top five Node.js frameworks

There are multiple frameworks which leverages the Node.js platform for catering to certain use-cases; the top five of them (basis the architecture, utility and preference) are mentioned below –

Express.js — Most popular of the frameworks; providing a rich collection of features for both web and mobile application development

Socket.io — Mostly used for event-based interchange of information

Meteor.js — Used for full-stack development of both mobile and web applications. This is compatible with all platforms such as Android, IOS, web as well as desktop

Koa.js — Specifically used for interactive web applications

Sails.js — Built on Express framework; Sails.js is mostly used in developing interactive applications such as chat-pods etc.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store