DEV Community

atul-mittal-07
atul-mittal-07

Posted on

6 Things You Need to Know About Javascript Engine

Let’s expose JS Engine and understand how and why this plays important role in making JS the most followed programming/scripting language in the world.

1 => console.log(“JS Engine is not a Hardware”);

Yes, JS Engine is not a piece of hardware that you install on your PC, Mobile, SmartWatch, or in Robots. This is just like a normal code that is written in another language to convert the JS Code into low-level (Binary) machine understandable code.

image

image

2 => console.log(“JS Engine is a part of JRE”);

JS Engine is a part of JRE(not JAVA Runtime Environment, as many of you would guess it!), JRE in the case of Javascript is Javascript Runtime Environment. JRE is a big container that contains a lot of peripherals(again not Hardware) and JS Engine interacts with almost all of them to solve problems in that particular platform.
image

3 => console.log(“JS Engine is different in different environment”);

It is a common notion that JS only works in Browsers like Chrome, IE(not anymore :D), Mozilla, etc. But that’s a complete misconception that is prevailing and it becomes very much imperative to understand that this is just JS Engine which most of the Browsers ship along with the Browsers already so that you don’t have to install it separately. JS Engine can even be installed standalone and the best example for that is Node.js and Deno.js which has given capabilities for JS code to run without even have to host them on Browsers and hence, they JS can now be used as a backend programming language as well like Python, JAVA, .NET, etc.

4 => console.log(“Implementation varies, end-goal is same”);

Different platforms (be it browser, standalone like Node, Deno, or robots) can have different implementations of JS Engine. For example, Chrome, Node, and Deno use Google-backed V8 engine which is written in C++. Mozilla on the other hand uses Spidermonkey which is written in C, C++, and Rust, a different implementation of JS Engine that works very differently behind the scenes but the end goal is the same, to give a faster performance, efficient computing, and bug-free environment to keep up the pace with the very fast development that is happening using JS in the real-world. Engineers across the world working day and night to make their engines stand out among all and they are really doing fascinating work. You can read more about JS Engines here.

5 => console.log(“Is it supposed to do only Interpreting!!??”);

Initial JS Engine which was created by JS creator Brendan Eich was supposed to do only interpreting of the JS Code, but as the time evolved, new apps started emerging and there was a need to have a bug-free, compiled, and more efficient JS platform. So later on, as and when new JS Engines were getting created, they were designed keeping in mind that the Engine should be capable of doing Interpreting and Compiling both. They should work hand-in-hand with each other to give best of the both worlds. Interpreting gives faster execution and compiling gives more efficient execution. The V8 engine is such an example that does both at the same time, its interpreter is known as “Ignition” and its compiler is known as “Turbofan”. You can read more about V8 here.

6 => console.log(“Best JS Engine as of now!!”);

V8, that’s it. There is no other engine that is even near to the capabilities which V8 has. Even the very first JS Engine created by the JS Creator which is Spidermonkey is not even near to V8. Its implementation is very much astounding and very well documented. You can read about all amazing algorithms like Mark n Sweep, Inline Caching which Google is using to create this V8 best in today’s world. You can have a detailed look on V8 here.

There are still a lot many things that are very much impressive about JS Engine but the above-given pointers are the most important ones I can think of.
image

Top comments (0)