What is Node.js?

Uriel Rodriguez
3 min readNov 9, 2020

--

My first introduction to JavaScript was during my time at a coding Bootcamp where I learned web development. And like most people when they encounter JavaScript, it was introduced for use on the front-end along with HTML and CSS. This makes sense since JavaScript was developed for use in the browser. However, when Node was created, it increased JavaScript’s utility, making it so that it could be used for server-side operations like querying a database or interacting with a machine’s file system. But despite these extended uses for JavaScript, Node itself does not execute JavaScript code, it only provides an environment that allows function outside the browser.

JavaScript is only executable with the help of a JavaScript engine. For example, the Chrome runtime uses Google’s V8 engine which is what handles and executes JavaScript code. Likewise, Node is built atop of the V8 engine, allowing Node to work with JavaScript code. This is because Node itself is a C++ program and a runtime that extends JavaScript’s functionality. So what is a runtime? You can think of it as a type of container or environment that provides custom functionalities, tools, and libraries. For example, the client-side runtime Chrome, which also uses C++, provides objects like the window or document object and functions for DOM manipulation which are not a part of the JavaScript programming language. It utilizes C++’s capabilities and extends them to JavaScript.

In addition, Node is a runtime that utilizes a non-blocking I/O model for handling its operations. Operations like accessing a file system or querying a database, also known as input/output operations take time. More commonly, a synchronous or blocking version of such an operation would require waiting for the results of the first operation before executing the second operation. This is known as blocking, where the second operation is blocked by the first operation’s process time. By using a non-blocking approach, or an asynchronous approach, the time it takes to execute these operations are cut shorter. Instead of waiting for the completion of the first operation, the second operation can be initiated immediately after the first. This allows two operations to process at the same time, and in the background, while and freeing resources to handle any other operations. And when the two operations are complete, then they are returned. This is concept is also borrowed from the client-side with the event loop and the message queue.

Finally, as I mentioned before, a runtime provides tools and Node gives access to the package manager known as NPM, or Node Package Manager. NPM is an ecosystem of open source libraries, or JavaScript code allowing developers to handle different tasks without having to rewrite certain logic on their own. One very popular library made accessible through NPM is React, the front-end JavaScript library for building UI components.

In conclusion, unlike the traditional front-end use for JavaScript , Node expanded JavaScript’s reach. The server-side runtime allows JavaScript to interact with back-end processes like querying databases. JavaScript can also utilize Node’s tools like the package manager to work with modules that allow additional functionality like creating web servers. Node also borrows features from the client-side like asynchronous processing, or non-blocking I/O operations. To learn more about Node or the package manager, NPM, you can check out their documentation.

--

--