Overview of Node.js

Yudhisha SJ
3 min readFeb 17, 2021

Everything you need to know

Understand why Node is named Node

Server-Side Rendering

You build simple single-process building blocks (nodes) that can be organized with good networking protocols to have them communicate with each other and scale up to build large distributed programs. Scaling a Node application is not an afterthought — it’s built right into the name.

Node.js is a JavaScript runtime environment. Sounds great, but what does that mean? How does that work?

The Node run-time environment includes everything you need to execute a program written in JavaScript. Node is raw and flexible. It doesn’t provide complete solutions, but rather provides a rich runtime that enables you to implement solutions of your own. Libraries like Express.js and Socket.IO are more complete solutions, so it makes more sense to teach those libraries, so you can enable learners to use these complete solutions.

Why Node.js?

Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.

I/O refers to input/output. It can be anything ranging from reading/writing local files to making an HTTP request to an API.

I/O takes time and hence blocks other functions.

Consider a scenario where we request a backend database for the details of user1 and user2 and then print them on the screen/console. The response to this request takes time, but both of the user data requests can be carried out independently and at the same time.

In the blocking method, user2’s data request is not initiated until user1’s data is printed to the screen. If this was a web server, we would have to start a new thread for every new user. But JavaScript is single-threaded

On the other hand, using a non-blocking request, you can initiate a data request for user2 without waiting for the response to the request for the user1. You can initiate both requests in parallel.

This non-blocking I/O eliminates the need for multi-threading since the server can handle multiple requests at the same time.

Learn the global variables that you can use like process, module, and Buffer

They’re all defined on a global variable (which is usually compared to the window variable in browsers). In a Node’s REPL, type global and hit tab to see all the items available (or simple double-tab on an empty line). Some of these items are JavaScript structures (like Array and Object). Some of them are Node library functions (like setTimeout, or console to print to stdout /stderr), and some of them are Node global objects that you can use for certain tasks (for example, process.env can be used to read the host environment variables).

Thanks for reading …!

--

--

Yudhisha SJ

Working as a Jr. Product Developer in the Infinitus Data Logic Pvt Ltd