I have been researching Interpreters/Compilers, then I stumbled across JIT-Compilation - specifically Google Chrome's V8 Javascript Engine.
My questions are -
- How can it be faster than standard Interpretation?
- Why wasn't JIT-Compilation used in the first place?
My Current Understanding
Every Javascript Program starts out as source code, then, regardless of the method of execution, is ultimately is translated to machine code.
Both JIT-Compilation and Interpretation must follow this path , so how can JIT-Compilation be faster (also because JIT is time-constrained, unlike AOT-Compilation) ?It seems that JIT-Compilation is a relatively old innovation, based off of Wikipedia's JIT-Compilation Article.
"The earliest published JIT compiler is generally attributed to work on LISP by McCarthy in 1960."
"Smalltalk (c. 1983) pioneered new aspects of JIT compilations. For example, translation to machine code was done on demand, and the result was cached for later use. When memory became scarce, the system would delete some of this code and regenerate it when it was needed again."
So why was Javascript Interpreted to begin with?
I'm very confused, and I've done a lot of research on this, but I haven't found satisfactory answers.
So clear, concise answers would be appreciated. And if additional explanation about Interpreters, JIT-Compilers, etc. needs to be brought in, that's appreciated as well.