The Engine consists of two main components:
* Memory Heap — this is where the memory allocation happens
* Call Stack — this is where your stack frames are as your code executes
Memory Heap & Call Stack
Compilation & Interpretation
First, let’s take a brief computer detour and discuss the distinction between compilation and interpretation. We already know that the computer’s processor can only handle 0s and 1s. As a result, every computer programme must eventually be turned into machine code, which can be accomplished by compilation or interpretation.
Compilation converts the full source code into machine code at once. After that, the machine code is saved as a portable file that may be run on any computer. So there are two steps to this. Machine code is created first, and then it is executed in the CPU, or processor. And the execution can take place after the compilation has been completed. For example, any application you are using right now on your computer was previously compiled, and you are currently executing it after it was compiled.
In Interpretation, on the other hand, an interpreter runs through the source code and executes it line by line. As a result, the two steps are not the same as before. Rather, the code is read and executed simultaneously. Of course, the source code must still be transformed into machine code, but this occurs just before it is executed rather than beforehand.
Let’s pretend we have a very basic programme. In the example, all it does is define a variable, and on the right-hand side, it seems like an AST for only one line of code. So we have a variable declaration with the name “a” and the value “23” that should be constant. Aside from that, as you can see, there is a lot of stuff here. Imagine how it would look in a large-scale real-world application.