KHEEM DHARMANI
2 min readAug 4, 2021

--

How NodeJS works behind the scene?

let’s start by learning a little bit about Node working. So let’s represent that structure in terms of Node dependence, which is a few libraries on which Node depends for efficiency. Node operating time, therefore, has several dependencies, and most important:

  • V8 engine
  • libuv

Node is a JavaScript run time based on Google’s V8 engine, right? And then, that’s why it seems as a dependency. If it were not for the V8, Node would have no way of understanding the JavaScript code.

What is V8 engine?

And of course, the V8 is an important part of the Node architecture. Also, the V8 engine is the one that converts JavaScript code into machine code that a computer can actually understand. And the V8 itself is written in C ++ code. But that alone isn’t enough to create a whole server-side like Node. And that’s why we also have libuv in Node.

What is Libuv?

And libuv is an open-source library with a strong focus on asynchronous IO. This layer is what gives Node access to a working computer program, file system, communications, and more. The important thing to note is that libuv is actually written entirely in C ++ and not in JavaScript. Apart from that, libuv also uses two of the most important features of Node.JS:

  • The event loop
  • The thread pool

And in simple terms, the event loop is responsible for handling simple tasks such as using telephones and network cables while the thread pool is for heavy work such as file access or compression or something like that. Node itself is a program written in C ++ and JavaScript and not just JavaScript. Now the beauty of this is that Node.JS binds all these libraries together, whether written in C ++ or JavaScript, and gives developers access to their works with pure JavaScript. So it really gives us a really good layer of extraction to make our lives a lot easier instead of liking dirt with the C ++ code. That would be a terrible thing, wouldn’t it? So again, this build allows us to write 100 percent pure JavaScript code, working with Node.JS and still accessing functions such as file readings, background scenes actually used in libuv or other libraries in the C ++ language. And when it comes to other libraries, Node actually relies not only on V8 and Libuv, but also on the HTTP-parser to split HTTP, ic-ares, or something similar for certain DNS application objects, OpenSSL for Keepography, and compression.

So at the end, when all these pieces fit together properly, we end up with Node.JS ready to be used in server-side applications. And next, you’ll learn more about the Node threads and the event loop.

So stay tuned for that.

--

--

KHEEM DHARMANI
0 Followers

As a highly skilled and experienced in content writing, with more than 5 years of academic studies.