DEV Community

Cover image for JS compiled language
GiandoDev
GiandoDev

Posted on

JS compiled language

The history teaches us that the compiler processes the code in three stages:

Lexing

Alt Text
As in the image above, in this phase, we convert our program into meaningful tokens.

Parsing

Here we take a stream of tokens (array) and trasform it into an abstract syntax tree called AST that represent the grammatical structure of the program.
Alt Text

Code Generation

Here JavaScript convert AST into a set of machine instruction.
Between parsing and code generation, JavaScript optimizes performance, execution and does also other cool stuff, all in a millisecond.
If you want take time to understand JavaScript engines look this awesome video from JS config Franziska Hinkelmann
Alt Text

Discussion (0)