Voice of a Developer: Javascript Engines - Part Three

JavaScript is a language of the Web. This series of articles will talk about my observations learned during my decade of software development experience with JavaScript, and what mistakes developers generally make and  what differences they should be aware of.

Part Three will focus in detail on JavaScript Engines. Before moving further let us look at the previous articles of the series:

Let’s start with Q&A:

Q: What is the difference between interpreted v/s compiled languages?

Ans:

Compiled: In compiled language, a compiler will translate the program directly into code that is specific to the target machine, which we call machine code. Then the computer will run the machine code on its own.

Interpreted: In an interpreted language the code is not directly run by the machine; there is another program which reads and then executes the code. This other program is known as the interpreter.

Q: Is Javascript an interpreted language or compiled language?

Ans:

Historically it was designed as interpreted language.

Javascript differs from traditional C, C++ lanauges. Javascirpt is JIT (Just-in-time) compiled. The reason behind this approach is for huge speed gains which modern Javascript engines provide.

Q: Which category of language Javascript belongs?

Ans: JavaScript is considered as a high-level language. It’s readable by humans easily.

Q: What is a a JavaScript engine?

Ans: It’s a program or library, which executes JavaScript code.

engine

Evolution of JavaScript engines

The 1st JavaScript engine was created by Brendan Eich in late 1990s for Netscape. It was named SpiderMonkey, and was written in C++.

Since after then there were many engines launched. Here is the list of popular ones:

Browser

JavaScript Engine

Mozilla

SpiderMonkey

Chrome

V8

IE & Edge

Chakra

Node.js

V8

PhantomJS (headless browser)

JavaScript Core

Q: Which Javascript engine scores high?

Ans: You can compare how various engines perform in benchmarking produced on http://arewefastyet.com/

scores

Q: How Javascript engine works?

Ans: Here is the process,

process

The parser takes Javascript and generates a Abstract Syntax Tree (AST).

AST: It’s just a syntax tree, and a tree representation of source code,

ex:

example

After AST is generated, there are two choices depending upon Javascript engine to generate bytecode

For ex- Google V8 & Chakra generates Native code and both are really fast engines to run JavaScript.

example

Read more articles on JavaScript:

Up Next
    Ebook Download
    View all
    Learn
    View all