Node.js is an open source javascript runtime environment used to build and script server-side programming logic for Websites and apps.
Let's have a deep dive into how the node.js runtime works!
The Javascript Engine!
The JavaScript code that we write is compiled by the Javascript engine on our browser most popularly the V8 Engine which interprets and compiles the code so that it can be implemented by the browser. The V8 breaks the javascript code into smaller pieces called 'lexical tokens' and then parses it. These tokens form a tree-like structure called an 'Abstract Syntax tree' or AST. it then interprets the code and sends it to the compiler which then converts the code into machine code which can be understood by our browser. The picture below shows the journey of javascript code.
What is LibUV?
The Logo is cool! although it's not a Dinosaur :)
LibUv is a library that can execute tasks including multithreading, file I/O and many other things which javascript cannot as it is a language that was built mainly to run in browsers.
context: Node bindings are codes written to act as a bridge between the javascript v8 engine and LibUV library
This javascript code that we write goes to the V8 engine and it sends the tasks that it cannot perform to libUv with the help of nodejs bindings libUV executes it and when it's done, the node bindings take the output and the v8 engine implements it.
LibUv is written in c language which gives it the power to execute tasks that include involvement of interaction with the operating system of the machine.