Inside JavaScript Engine

Avinash Yadav
3 min readJun 30, 2020

--

If You want to know about How V8 Engine came into Existence Check out my Previous Blog CLICK HERE .

The Below Image Shows the Structure Inside the JS Engine .

This is some how the javaScript Engine looks from Inside

The JavaScript File is taken by JavaScript Engine and the following Process is done inside it .

  1. Parser takes the JS File and Perform Lexical Analysis which breaks the Code into Tokens to identify there Meaning so that we know what the code is trying to do. These Tokens are Formed into AST [ Abstract Syntax Tree ]

2. AST [ Abstract Syntax Tree ]

There is a Fun little Tool Which helps You Understand the Demo of AST . Go to https://astexplorer.net .

This Allows Engine to Understand what is happening in the program and break down things one by one .

BEFORE GOING TO NEXT STEP LET`S TALK ABOUT INTERPRETER AND COMPILER

Interpreters and Compilers are the important parts of our JavaScript Engine.

You see in Programming these are generally two ways of translating to machine Language that our computers can understand . This actually applies to most Programming Languages and not just JavaScript , like python ,Java, C++ .

Any Language You think of is going to use these Concepts.

3. Interpreter : interpreting code simply means taking a set of instructions like we have over here and returning an answer and doing something with that code. It’s just like me telling a computer to do this. Then do that ,then do this and initially that’s how JavaScript worked it was interpreting using an interpreter.

4.But what about a Compiler. What’s the deal with a compiler.Well a compiler like an interpreter doesn’t translate on the fly.

What it does is it works ahead of time to create a translation of what code we’ve just written and it compiles down to usually a language that can be understood by our machines.

In Basic Terms , it goes through the Code once and try to understand What the code does

It takes the code in one language and Translate the Code into Another Language with the Same Results .

i.e HIGH LEVEL LANGUAGE [ JavaScript ]to LOW LEVEL LANGUAGE [ Machine understandable Language i.e 0`s & 1`s]

-Interpreter Spit`s out Byte Code and Compiler gives Machine Code

But the main takeaways is this there are two ways to run JavaScript using an interpreter or a compiler.

Interpreter is Fast and Running but Compiler make the Code Optimized and Faster to Run.

--

--