Understanding the JavaScript V8 Engine

July 30, 2019

Have you ever heard of the term V8 engine when talking about either Chrome or JavaScript or even Node.js. Ever wondered what actually V8 engine is?

In this article, I will be explaining to you what is V8 engine & what is its use.

The V8 Engine

V8 Engine is an open source JavaScript engine build using C++. It was built for the Chromium Project & the Chrome browsers, but nowadays, is the base for other JS based technologies like Node.js, MongoDB etc.
V8 Engine is a stand-alone project that is complete in itself as a JS engine. It has no dependency on the Chrome browser or anything like that.

But what is a JS Engine?

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.

Deep Dive into the V8 Engine

Many traditional languages like JAVA, C# etc compiles the code and create a bytecode or an intermediate language & that code is finally executed by the machines. Creating the bytecodes is an additional overhead for the compiler. This is what the V8 engine developers understand & they made it capable of directly compiling the JS code into the machine language, a language that can be run directly by the operating system. The engine also optimizes the code dynamically at runtime based on heuristics of code execution profile. Hence, it makes V8 Engine a super-fast JS Engine.

Besides this, the V8 engine uses other optimization techniques like
  • Inline Expansion — Replacing the function calls with the corresponding function blocks
  • Copying Elision — Preventing the expensive tasks of copying some objects
  • Inline Caching — Caching the execution of some older tasks that can be look up while executing the same task in future


V8 engine is intended to be used in a browser, as used in the Chrome browser & it can also be used as a standalone JS engine for various projects like:
  • Node.js
  • MongoDB
  • Couchbase database

You Might Also Like