Wednesday, March 18, 2020

Node.js Quick Overview

Node.js Quick Overview

Node.js is a JavaScript runtime environment. It is an open-source, cross-platform, asynchronous runtime environment capable of running JavaScript code outside a web browser. The Node.js uses a V8 engine under the hood. The V8 engine is also known as the Chrome V8 JavaScript engine under the Chromium project. The programmer can write command-line tools and the scripts can be executed at the server-side to generate dynamic web content that can be later displayed at the user’s web browser. Ultimately, Node.js reflects a "JavaScript everywhere" paradigm, to unify web-application development with a single programming language. This enables the programmers to use the same programming language at the server-side and client-side.

The design of Node.js ensures high throughput and scalability in web projects with several IO operations, even for the real-time Web, distributed web applications and browser games.

Features of Node.js

  • Fast
  • Asynchronous
  • High scalability and throughput
  • Best suited for real-time, in-browser and gaming applications.
  • Encourages sharing
  • Secure and reliable
  • Highly compatible with JSON supported and real-time databases
  • Unified API 

Node.js features
Node.js Features

Event loop and Threads

The Node.js core API is based upon an asynchronous event-driven architecture and Node.js is perfectly suitable for event-driven applications. Node.js provides a runtime environment that processes incoming requests in a loop; this is generally known as the event loop. Node.js works upon a single thread event loop model, which uses non-blocking Input/output calls. This allows Node.js to support millions of concurrent connections without any additional cost of thread context switching. The Node.js uses the libuv library which is based on a constant-size thread pool to handles several non-blocking asynchronous Input/output operations to accommodate a single-threaded event loop.

Unified API

Node.js can work with a web browser or it can execute server-side scripts asynchronously. It can also interact with JSON data supporting databases like MongoDB, CouchDB or Postres, etc. It can be used with server-side development patterns such as MVC, MVP, MVVM, etc. The programmers can reuse a similar model and service interface between client-side and server-side components. Overall, Node.js provides a unified API for diverse applications.

These days several corporate giants like GoDaddy, IBM, Microsoft, LinkedIn, Walmart, Netflix, Paypal, Voxer, SAP, Yahoo are using Node.js worldwide.

A brief history of Node.js

In 2009, Node.js was developed by Ryan Dhal. The initial release of the Node was written for Linux and the Mac only. The development and maintenance of the Node.js were led by Ryan Dahl and later it was sponsored by Joyent. The first version of npm was also introduced in January 2010. The npm is a package manager that makes it easier for the developers to publish and share the source code of Node.js libraries. The npm is designed to make npm libraries installation, updating, and uninstallation easy and simple.

Microsoft and Joyent introduced a native Windows version of Node.js. The initial Node.js build supporting Windows was released in July 2011.

In 2015, The Node.js Foundation came into the existence and IO.js is merged back into Node.js.

In the same year, npm introduced private modules.

In 2017, npm focuses more on security and Node.js version 8 was released. In the same year, Chrome V8 introduced Node.js in the official test suite that made officially made Node.js a target for the JS engine, in addition to Chrome.

Node.js version 10 was launched in 2018.

Node Architecture

Node.js is based upon an event-driven, non-blocking I/O model. This is a lightweight, minimal framework based on the V8 engine.

Node.js Architecture
Node.js Architecture