🎗️v8 javascript engine in Node.js🎗️

🎗️v8 javascript engine in Node.js🎗️

What Is the Relationship Between Node.Js and V8?

Have you ever heard of the term V8 engine 😃when talking about either Chrome or JavaScript or even NodeJs.

Ever wondered what actually V8 engine is?🤐

In this article, we will look into Node.js and V8. Node.js is a very important part of the JavaScript ecosystem, as it is used in the backend to produce a complete application.

The V8 engine is what powers💪 Node.js and it is an open-source engine on which even Chrome works. It parses and runs your JavaScript inside a Node environment.

The V8 Engine💥

So yes,“V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++” (V8 documentation) but what does this actually mean?🤯

Well, actually it means, V8 is a C++ program, which receives JavaScript code, compiles, and executes it.

  • So what actually is a Javascript Engine?🙄

Javascript Engine💫

It is a program that converts Javascript code into lower level or machine code that microprocessors can understand.

A JS engine is a compiler that takes JS code, compiles it & runs it on the device running the V8 engine😮‍💨.

JS Engine is the core for running a JS code. There are other engines available in the market as well, like the Apple Safari 4’s Nitro and Mozilla Firefox 3.5’s TraceMonkey but in this article, I will only be covering the V8 engine.

What is Chrome V8?😬

Chrome V8 is a JavaScript engine, which means that it executes JavaScript code. Originally, JavaScript was written to be executed by web browsers. Chrome V8, or just V8, can execute JavaScript code either within or outside of a browser😲, which makes server-side scripting possible.

Like a V8 (eight-cylinder) car engine, Chrome V8 is fast and powerful. V8 translates JavaScript code directly into machine code* so that computers can actually understand it, then it executes the translated, or compiled, code. V8 optimizes JavaScript execution as well.

What is Node.js?

Node.js is a runtime environment for executing JavaScript code, and it is built on the Chrome V8 engine. It is asynchronous, which means that it does not have to wait for one process to complete before starting another one.

(Those familiar with JavaScript will note the '.js' file extension; however, this is purely an aesthetic choice for the runtime environment's name to indicate its association with JavaScript and does not mean that Node.js is a JavaScript file.)

A runtime environment is the software environment in which code is executed.

v8 in relation to Node.js 👫

Chrome V8 executes JavaScript code. Node.js is built on top of Chrome V8 and is a widely used runtime environment for serverless JavaScript functions.

The system that compiles the javascript files into machine code and also manages the program's memory is called javascript runtime🤠.

Chrome V8 engine originally ran in Chrome web browsers. But later it was used to run the javascript without a browser and that is exactly what Node.js is. Node.js is written in C++ and built on top of the Chrome V8 engine which is also written in C++. V8 provides the runtime for the Javascript.

What is the use of V8 Engine in Node.js ?🤔

We know that JavaScript is used to write programs in Node.js. JavaScript is a very high-level language that can’t be understood by microprocessors. Node.js is developed by V8 JavaScript Engine that is written in C++ language.

So, we can see that Node.js is written in C++ language. So, hierarchy says that all the JavaScript code is executed by the V8 JavaScript engine; which converts the code into Assembly code and this assembly code further converts it into machine code🤓

So, now we know what is Chrome V8 engine and the roles played by it in the Node.js for making Javascript really fast and performant.

That's all for the day......🙆‍♀️

Did you find this article valuable?

Support Chhakuli Zingare by becoming a sponsor. Any amount is appreciated!