Getting Started with NodeJs

Search for a command to run...

No comments yet. Be the first to comment.
💡 “So if you want to go fast, if you want to get done quickly, if you want your code to be easy to write, make it easy to read.” -By Robert C. Martin JavaScript has progressed a ton in recent years. If you are learning JavaScript in 2022 and you ...

Before beginning our quest to find how not to use Create React App. First, let’s see why we need Create React App in the first place. Why do we need Create React App? 🤔 Create React App is a comfortable environment for learning React and is the best...

If you are reading this, you probably know what React.js is and might have already used it Earlier. However, you might be wondering why I am reading about folder structure? Can’t I just stuff all my files in the src folder?? 🤪 Technically you could ...

Let’s first understand 🤔 What is an Array? Quoting from MDN directly. The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name and has members for performing common...


In this blog, we will try to understand the basics of Node.js, how it works, and why to choose Node.js, but before diving into node let's talk a little bit about Java-script.
JavaScript is one of the best programming languages available nowadays. It was developed in the year 1995 but at that time it was just a client-side language i.e. it can run over browsers only. So if one wanted to make a website can use HTML for designing, CSS to make it attractive and java-script to make it interactive.

But then a question arises if javascript is a programming language, how browser runs it, and here javascript engine comes into the picture. A JavaScript engine is a software component that executes JavaScript code. The first JavaScript engines were mere interpreters, but all relevant modern engines use just-in-time compilation for improved performance. Every browser has a javascript engine like Chrome uses V8, Edge uses Chakra and Firefox uses Spider Monkey. When V8 was developed it was very fast compared to others, and the idea of using JavaScript everywhere came and NodeJs was developed.
Node.js is an open-source, cross-platform, back-end JavaScript runtime environment developed in the year 2009 that runs on the V8 engine and executes JavaScript code outside a web browser. Node.js lets developers use JavaScript to write command-line tools and for server-side scripting-running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.
Node.js represents a "JavaScript everywhere" paradigm, unifying web application development around a single programming language, rather than different languages for server-side and client-side scripts.
Further, a package manager was introduced for the Node.js environment called node packet manager (NPM). The package manager makes it easier for programmers to publish and share the source code of Node.js packages and is designed to simplify the installation, updating, and uninstallation of packages.
Node.js works in a Non-blocking or Asynchronous way. Let’s try to understand the Asynchronous architecture. Imagine you visited a restaurant, a waiter comes to your table and takes your order and gives it to the kitchen, and moves on to serve another table while the chef is preparing your meal. So the same person can serve many different tables, this is what we call non-blocking or asynchronous architecture and this is how node applications work, here the waiter is like a thread allocated to handle a request.

Also, Node.js is an event loop single-threaded language, here event loop is what allows Node.js to perform non-blocking I/O operations and explains how Node.js can be asynchronous. The event loop allows running one thing at a time. Having said that, Node.js JavaScript code runs on a single thread. The beauty of the event loop is not of running everything in a single thread, but it’s available to “put aside” long time-consuming I/O operations to keep the execution of other instructions. This is the reason why we get fast responses even though we could have multiple users making requests to a Node.js API at the same time. .
From the above discussion, we can conclude that Node.Js is a good option for less CPU-intensive applications, we can build things in Javascript top-to-bottom, even down to the database level if we use JSON storage Object database like MongoDB but much CPU intensive computation will block Node.js responsiveness, so a threaded platform is a better approach.
In the next part of the blog, we will see what happens when we type a URL in the browser, further we will get into the basics of backend development using NodeJs.