Sirwin
Sirwin

What is node.js

By 0xgult | 0xcoding | 28 Mar 2020


node.js is a Javascript runtime built on Chrome's V8 Javascript engine.

node.js is NOT a programming language!
node.js IS a runtime!

If you know Java, a simple analogy to understand this is node.js is similar to the Java Runtime Environment and the V8 engine is like the JVM where the applications are actually run.

node.js now enables Javascript to be run on your machine with access to I/O, file system etc. where once Javascript was only used to manipulate the DOM. Now you can do much more with Javascript than making websites interactive.

What is Blocking IO?

Typically when a web server receives 2 requests request1 and request2, the request2 is not initiated until the request1 is fully completed. This is where the web server would have to create multiple threads to concurrently process multiple requests. But Javascript is single-threaded! So how do we solve this issue?

Non Blocking IO

In this scenario, request1 and request2 are made asynchronously without having to wait on each other and also without having the need to have multi-threading. This is where node.js really shines!

So the best use cases for node.js are when you have an I/O intensive application which can either be using the file system or HTTP requests to an API.

node.js is not the best solution when the operations are CPU intensive in which case it might not make sense to use a lot of asynchronization.

How do you rate this article?

4


0xgult
0xgult

I write crypto things!


0xcoding
0xcoding

Programming related blog

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.