NodeJS: What and Why?

Sakshi Sawant
Dev Genius
Published in
4 min readMar 7, 2022

--

NodeJS is a javascript runtime environment

Photo by Clement Helardot on Unsplash

According to the official NodeJs documentation, NodeJs can be defined as an open-source and cross-platform, backend Javascript runtime environment that can be used to create any type of project.
Since the definition itself is complicated to understand so now let’s break the definition into words and understand what exactly it means, So NodeJS is an open-source and cross-platform means NodeJs is freely available to use, share, and can even be modified by anyone, and cross-platform means we can write nodejs code in a way that will be able to execute in any operating system like Windows, Linux, or Mac.

So now what does javascript runtime means?
Javascript runtime simply means a place where our javascript code is executed when we run our code. With that said, today javascript can be executed on any device which has a program called a “Javascript engine”. This javascript engine has different names according to different platforms, for example, On google chrome browser it is called the V8 engine, on Firefox it is called as SpiderMonkey and on Safari it is JavascriptCore.

So now what is a javascript engine?
Javascript engine is simply a program that helps in converting the javascript code into machine understandable code.

To summarize, nodejs is a javascript runtime environment used to create servers and perform backend operations in javascript for developing real-time scalable applications.

Why should we use NodeJS?
Programming with nodejs gives the advantage to develop both frontend and backend using one programming language that is javascript, so the javascript programmers have an edge and comfort in mastering a single programming language rather than learning different languages for frontend and backend.
Apart from this, Nodejs runs on chromes V8 engine which improves the performance of the Nodejs and allows doing asynchronous operations.
Asynchronous means doing the operations concurrently at the same time, hence with nodejs it is possible to perform asynchronous operations without increasing the load on the server.

NodeJs

Nodejs comes with npm(node package manager) which is the default package manager for the node, hence with npm, we can reuse the code which is already present and also develop our own packages for others to use which saves development time.

How nodejs is different from javascript?
Since nodejs uses javascript, so many new developers get confused with both of them, here are a few major differences,

  • Javascript is a programming language whereas nodejs is a javascript runtime environment
  • Javascript runs on the browser but with the help of nodejs, we can run javascript code outside of the browser too.
  • Javascript is a client-side scripting language hence used to create the frontend while nodejs is used as server-side scripting language which is used for creating the backend of the application.
  • With nodejs, we can perform file and operating systems operations whereas with javascript we can perform browser-specific operations and very few operating system operations like uploading files, etc along with certain permissions.

Disadvantages of nodejs
Up till now, we have seen what is nodejs, why we should use it now let’s see when we should not use nodejs.

  • Since nodejs uses an asynchronous programming model it becomes difficult to maintain code as the application increases in size.
  • It should not be used when performing heavy computation tasks on the server.
  • Since various npm modules are available to use, they should be chosen wisely as some of them may contain poor quality code and documentation.

Real-world applications
As now we have seen all the pros and cons of nodejs and why we should use it so now let’s see some of the most popular real-world applications which people around the world use in their daily life.

Linkedin — The networking platform for professionals

Paypal — Payments application

Trello — Project management application

Uber — anytime and anywhere car service

Hence, nodejs is widely been used by most tech companies so learning nodejs is definitely the best option if you want to use it for the backend of your next project.

Summary:

  • NodeJS is a javascript runtime environment that runs on chromes V8 engine.
  • Used for developing the backend of the application.
  • Allows performing asynchronous operations.
  • Can be used for developing real-time scalable applications.

--

--