Node.js or simply Node is an open source runtime environment for executing javascript code.
What does it mean by runtime environment?
A runtime environment is the objects and classes that are required to run some code. Consider it as a container that executes the code.
Example, in javascript you can fetch an element by its id using document.getElementById function. Support for this document object is provided by browser runtime environment.

Till now you might have heard that javascript can be executed only inside a web browser. But node enables executing javascript code outside of a browser.
Node is used to build backend services or APIs. In simple words, node is used to write server side code.

Node is created using Chrome browser’s V8 javascript engine embedded inside a C++ program as shown below.
node runtime environment
Thus, node is a runtime environment for javascript code similar to browser in that both use the same engine.
Node provides additional capabilities such as interacting with database, filesystem, network etc. which are not available inside a browser.

One might ask that this can be done using many frameworks out there such as ASP.NET, Django, Spring etc. But there are many features that make node stand out of already available tools.
These features are explained next.
Why node.js
Node.js provides many reasons to choose it.
They are
1. Node can be used to create highly scalable and fast applications.
2. Node applications are written in javascript. This means you can write both front end and backend yourself if you know javascript or by learning it.
3. Since node uses the same language at both front and back ends, your codebase becomes more consistent since you can use the same naming conventions, tools and logic everywhere.
4. For most of the features you require in your application, there are bright chances that there is some open source library already available.
This means that there is no need for developing that feature from scratch, you will get it ready made. This is due to a large ecosystem of libraries that are available to use with node.
Node.js Features
Node.js has many distinguishing features which make it a modern choice for creating backend services.
1. Asynchronous request processing
Asynchronous means non-blocking. Suppose a request arrives at node to read a file and return its contents.
Node does not wait for the file to be read instead, it performs this operation in background and receives another request. This is called asynchronous processing and this is what makes node very fast.

One might argue that all server side frameworks work in the same way in that they allocate a separate thread for each request which is responsible for processing that request.
But when there are many concurrent requests, the application might run out of threads and it may be required to add more hardware but with node it is never required.
2. Single Threaded
As explained above, node uses a single thread for request processing which minimizes the need for heavy hardware.
3. Very Fast
Node is built on Chrome’s V8 engine which highly reduces its request processing time.

Node website describes it as

Node.js is a Javascript runtime built on Chrome’s V8 Javascript engine. Node.js uses an event driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystemt, npm, is the largest ecosystem of open source libraries in the world.

2 Comments

  1. Right now, node.js is quite popular among web developers and many companies. I am also a newbie in this field. so, I visit each day a few websites to read posts, but Your weblog gives feature-based writing. My appreciation and thanks to you. Continue the good work!

Leave a Reply