How Javascript runs — The Javascript Engine

Taking a deep dive into Javascript to understand it inside out.


Allan Sendagi

3 years ago | 2 min read

I am taking a deep dive into Javascript to understand it inside out.

I will be writing a series on what I have researched and learned. But most importantly, perhaps, is that I welcome your input — yes you the reader; the input and corrections if you see that I am missing something or you have something important that you want to add.

We will build from the ground up.

And so the first question is:
How come I can write code in my sublime text and it ends up as instructions to the computer?

And the second question:
How does a browser read this file from my Editor? How is Javascript executed? How does node.js work?

And more questions:
Why is Javascript called a Single-threaded language? I have heard people say that javascript uses a callback queue and others have called it an interpreted language?

The Javascript Engine

We know that at the end of the day, a computer understands only 1s and 0s. This means that a computer has no idea what javascript is. So how come it can understand what we write in a text editor?

This is made possible by the javascript engine. The engine acts as a translator and interprets our code into the language that a computer understands.

Without the engine, it's pretty much like speaking Luganda(my local dialect) to a computer and expect it to understand.

There are many Javascript engines. And although you can write yours, there is a standard (Ecma script engines). Well, because as you can imagine if everybody created their own engines, it would be total chaos.

So, Ecma Script tells engine creators how the language should work but internally it's up to you how you create the engine as long as it conforms to the set standards.

And engines are written by programmers. The first Javascript engine(Spider Monkey still used by firefox) was created by Brendan Eich — the creator of the javascript language while working at Netscape. After his creation, you could run Javascript on a browser that previously could only read HTML and CSS.

But 2008 was a very important year for Javascript because that's when Google built its V8 engine which is arguably the fastest engine for the language so far.

The reason for the creation was because google maps required a lot of power (zoom in, zoom out, street view, etc ) and the engines at a time were slow and obviously because google wanted people to use their search engine and control more of the market.

Smart people work on these engines to ensure our javascript code works on a Browser, server or any type of computer.


Created by

Allan Sendagi

Technology will save homo sapiens from extinction







Related Articles