A Journey into Just-In-Time Compilation in Javascript Language — Part - 1
Hey Guys, In this Digital age, computer programming has become a very crucial factor in all fields. From Business Development to Electronics, computer programming is being used for multiple purposes. So now the question is, how does a machine, which is a combination of transistors and switches understands these programming languages? How does it execute instructions from multiple languages like C, C++, Python, Javascript etc?
To answer this question, first we need to know what computer understands. The computers are electronic machines that can only understand and interpret 0’s and 1’s(Binary bits). Everything in the computers, starting from Video games to small scale software, all these are represented in binary bits. The CPU is the brain of the computer, its whole purpose is to interpret this binary bits, understand what this does, and perform what the binary bits are meant to do. The CPU executes the “Instructions” by interpreting these binary bits. For examples, consider the following binary bits.
01000001 01000010
If you look at the above binary bits, you may interpret it in multiple ways. If you represent the above binary bits as a string, it means “q” and “r”. If you represent the above binary bits as a CPU instruction, it means “jno 0x74”, which is an instruction that CPU understands. Like this, it’s the responsibility of the CPU to decode this binary bits and perform the action intended by this binary bits. This language is called “Binary or Machine language” and the above binary bits are called “Binary code or Machine code”. In earlier days, when we were using punching cards for input and magnetic tapes for memory, programming the computers in binary language is not that tough. But when the technology got advanced and the information it processes became large, it became a tedious task for the programmers at that time to program the computer using the machine language and machine codes. So they came up with the concept of “Programming language and Compilers”.
The idea is pretty simple, create a program or source file which can be human readable and understandable by humans, then translate this human readable source file into machine understandable binary bits. For example, write the code in the below human readable format
int main() {
printf("Hello world");
return 0;
}
and translate them into machine codes as given below
01001000 10001101 00111101 10101001 00101111 00000000
The above mentioned translation is not an exact translation. It’s given only for understanding purpose. The translation of this source text or source code into machine is called “Compilation” and the software that performs this operations is called a “Compiler”.
In the next article, we will have an abstract representation of how a compiler works and what are the phases of a compilation that the compiler performs.