👨‍💻 An Introduction to Node JS

Alessandro Marchesin
5 min readMar 8, 2023

Did you know that you could manage a full-stack development with Javascript only? I agree that Javascript should be used only in client-side environments, mainly in managing website logic. Then what? I had the opportunity to follow a Skillshare course about the Node.js framework, and my idea changed!

What is Node.js? This server-side JavaScript platform has taken the web development world by storm, offering a revolutionary approach to building scalable applications that can handle massive traffic. Whether you’re a seasoned developer or just starting, Node.js is a game-changer that can take your web development skills to the next level.

In the following sections and articles, I will tell you more about its story, how it works, and how you can build a RESTful API, a web app GUI and a terminal-based command line program without dependency.

A bit of history

Not an easy start

In March 2011, a video began circulating on YouTube and being emailed from one developer to another. In the video, a scraggly twenty-something named Ryan Dahl lectures a small group at a San Francisco PHP meet-up about a new way of running Javascript.

On the server, he said he had packaged up Chrome’s V8 runtime so that it could interpret JavaScript server-side on any UNIX-like machine.

And then he added some valuable APIs to it. He was calling his creation Node.Js. Eventually, this video would garner hundreds of thousands of views and helped propel Node into the spotlight for many developers.

Ryan Dahl had authored Node two years earlier in 2009 and had been giving presentations at meet-ups, conferences and elsewhere since then.

Ryan had been a Node evangelist for years. has been challenging even if his first presentation, shortly after authoring the framework, he gave at a Javascript-centric conference in Europe in 2009 and ended in a standing ovation for Ryan. Since then, the broader programming community hasn’t been so welcoming: developers did not need Node.

The first turnaround

But in 2010, his luck started to change. First, in January 2010, Isaac Schlueter created a package manager called NPM, the node package manager. It allowed developers to share packages quite easily. No longer did the deaf have to search through disparate projects hosted in various ways in various programming languages to find the one that suited their needs and runtime. Developers structured every package on NPM in a way to make it usable in anyone else’s Node project, and each one was semantically version so that the user could predictably manage their dependencies.

This practicality made Node much more user-friendly and allowed developers to externalise the time costs of bootstrapping. Their projects address bugs in their code. One developer could tackle one issue, Let’s say, integrating with a database, while the other could tackle another, Let’s say, integrating with an API. And then they could share their code. After all, in these early days, Node was unstable and gave cryptic error messages when something went wrong.

We work with it now; a developer might spend considerable time tracking obscure bugs back then. NPM made writing Node much less isolating and much less frustrating.

The Second Deus-Ex Machina

In other early days, Node was born in symbiosis with an obscure database project built around the same time as Node and was also experimenting with V8 and being evangelised around the tech community then: MongoDB. In early 2009 a few entrances were competing for the title of NoSQL database, but you only sold a little of the developing world on the idea of no sequel. It was still a new idea; many Devs already had their databases.

Why would any pragmatic developer want to switch their tooling around to embrace a new DB, especially one that worked so utterly differently from anything they used to? One that didn’t even support sequel queries? One that stores data in a binary form and JSON format that was largely unfamiliar to most.

Even developers who routinely integrated with third-party APIs had no use for JSON as most APIs exposed themselves over XML or SOAP at that time. But in the late two thousand, the meteoric rise of social media sites started to change. That APIs like Twitter’s started being released and became wildly popular among developers. These APIs almost exclusively exposed themselves over REST with JSON.

So in the late two thousand, any developer who wanted to integrate with social media APIs, which was many of them, had to become familiar with JSON and the languages and frameworks they worked in had to begin supporting it. So as social media sites grew in popularity and standardized things like GraphQL and REST, they spread, and soon most new public APIs were being released RESTful with JSON.

And as more and more developers were fetching data in Jason, the idea of and the attractiveness of a JSON-based document store started to make sense to them.

Nowadays

So, what is Node today? Node.js is an open-source, cross-platform, server-side runtime environment built on the Google V8 JavaScript engine. Node.js runs JavaScript code outside the web browser, on the server side, using an event-driven, non-blocking I/O model. This means that Node.js applications can handle multiple concurrent connections without blocking the execution of other tasks, making them very efficient and fast.

Here’s a basic overview of how Node.js works:

  1. The client sends a request to the server: When a client sends a request to the server, Node.js creates an event loop to handle the request.
  2. Node.js creates a thread: Node.js creates a new line to handle the request, so the main event loop can continue to process other requests.
  3. Event-driven programming: Node.js uses an event-driven programming model, which waits for an event to occur and then performs the appropriate action. For example, when a client sends a request, Node.js waits for it to arrive and then triggers an event to handle it.
  4. Non-blocking I/O: Node.js uses non-blocking I/O to perform I/O operations without blocking the execution of other tasks. It allows Node.js to handle multiple connections and large amounts of data efficiently.
  5. JavaScript code execution: Node.js runs JavaScript code using the Google V8 engine, which compiles JavaScript code to machine code for faster execution.
  6. Response to the client: When the Node.js application has finished processing the request, it responds back to the client.

In summary, Node.js uses an event-driven, non-blocking I/O model to efficiently handle multiple concurrent connections and execute JavaScript code on the server side. This makes it popular for building fast, scalable, high-performance network applications.

In the following sections, we will go through a Node project and understand how you could write a RESTful API or a web app without extra libraries or dependencies, stay tuned!

--

--