NODE.JS

Ram Mohan Patel
3 min readMar 29, 2024

To put in simple words Node.Js is a cross-platform runtime environment(environment at the time of execution of code) which allows to run Javascript outside the browser.

Evolution

Earlier JS can only run in browsers which have an engine to run JS, for example Chrome has V8 engine, Mozilla has Spider Monkey engine, Opera has Carakan engine etc.

But in 2009 Ryan Dahl (Programmer) combined chrome’s V8 engine, event loop and low-level I/O API (allows developers to interact directly with system’s I/O capabilities).

Applications & Benefits

Image below perfectly covers the applications of Node.JS

Source

Benefits

  • Easy to learn
  • Offeres Scalability & high Performance
  • Single Programming language (JavaScript)
  • Advantage of Caching
  • Large Community & Extended Support

Architecture

When a request comes to a Node.js server, it enters an event queue. The event loop continuously checks this queue for incoming events. If the request is asynchronous (non-blocking), Node.js processes it within the event loop, meaning it doesn’t wait for the operation to complete and can handle other tasks in the meantime. Once the request processing is finished, Node.js sends back the response.

However, if the request is synchronous (blocking), Node.js doesn’t handle it directly within the event loop. Instead, it assigns a thread from the threads pool to execute the blocking operation. This prevents the synchronous operation from blocking the event loop, ensuring that Node.js remains responsive to other requests. Once the operation is completed by the thread, Node.js sends back the response. We can think of thread as a worker whose job is to complete the given requests. So If there are too much blocking requests then it will cause a long waiting time as the number of workers are limited.

It’s important to note that Node.js is designed for asynchronous, non-blocking operations, and it’s generally recommended to avoid synchronous operations whenever possible to maintain the scalability and responsiveness of the server.

Node Package Manager (NPM)

In January 2010, a package manager was introduced for the Node.js environment called npm. The package manager allows programmers to publish and share Node.js packages, along with the accompanying source code, and is designed to simplify the installation, update and uninstallation of packages.

Community Support & Trends

Open-Source community has developed several frameworks to accelerate development of applications. Such as Express.js, Socket.IO, Connect, Feather,js, Koa.js, Hapi.js etc.

Even Modern IDEs provide built in features for editing & debugging Node.Js applications. Although Node.js natively supports JS only but many compile-to-js languages are available. As a result Node.js can be written in TypeScript, CoffeeScript, Dart, ClojureScript & others.

Trends

source

I don’t think there’s anything to tell about Node.JS popularity after looking at above graph😊.

Thank you for reading my Node.js blog! Your interest and support mean the world to me as we strive to provide valuable insights and knowledge to our commmunity. 🚀

--

--

Ram Mohan Patel

I'm a 3rd year UG at IIT Kharagpur and I love technology.