YouTube Icon

News & Blogs

Node JS—What is It? What is Used For? Why Should You Learn It?

fluid
Node JS—What is It? What is Used For? Why Should You Learn It?11 Jun, 2020

Node JS—What is It? What is Used For? Why Should You Learn It?

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.js came into existence when the original developers of JavaScript extended it from something you could only run in the browser to something you could run on your machine as a standalone application.

Now you can do much more with JavaScript than just making websites interactive.

JavaScript now has the capability to do things that other scripting languages like Python can do.

Both your browser JavaScript and Node.js run on the V8 JavaScript runtime engine. This engine takes your JavaScript code and converts it into a faster machine code. Machine code is low-level code which the computer can run without needing to first interpret it.

We already discussed the first line of this definition: “Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine.” Now let’s understand the other two lines so we can find out why Node.js is so popular.

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.

Blocking I/O

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 (not really, but it has a single-threaded event loop, which we’ll discuss a bit later). So this would make JavaScript not very well suited for multi-threaded tasks.

That’s where the non-blocking part comes in.

Non-blocking I/O

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 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.

Advantages of Node.js

  1. Node.js is an open-source framework under MIT license. (MIT license is a free software license originating at the Massachusetts Institute of Technology (MIT).)
  2. Uses JavaScript to build entire server side application.
  3. Lightweight framework that includes bare minimum modules. Other modules can be included as per the need of an application.
  4. Asynchronous by default. So it performs faster than other frameworks.
  5. Cross-platform framework that runs on Windows, MAC or Linux




Have A Look Creative News

731ab9ad4a64dbf8ddbd178c87a0588a.png 28 Mar, 2024

Top Advice for Beginner Go Programmers

A companion on LinkedIn inquired me for pointers for a companion of theirs setting out on a travel to learn Go. Since my list of pointers distant s...

7a6d6b55c7448c4c5d2d9930e7d2c134.jpg 25 Oct, 2023

Top 5+ Tools For Remote Developers

Are you a inventor that has made the trendy shift from the office to remote work? Or are you looking to conceivably work from home via a new positi...

6fffb1d49ee894fe09ff88fb1267a3ea.png 22 Sep, 2023

Top 3 things the best senior developers do

Working under the care of a more educated inventor can make or break a inferior inventor's career. Then are 3 effects the stylish elderly inven...

CFG