I have some doubts about a JIT Compiler and an Interpreter. Starting from their definitions:
(Interpreter) From Wikipedia:
In computer science, an interpreter is a computer program that directly executes, i.e. performs, instructions written in a programming or scripting language, without previously batch-compiling them into machine language. An interpreter generally uses one of the following strategies for program execution:
1) parse the source code and perform its behavior directly
2) translate source code into some efficient intermediate representation and immediately execute this
3) explicitly execute stored precompiled code made by a compiler which is part of the interpreter system
(JIT COMPILER) From Wikipedia:
In computing, just-in-time compilation (JIT), also known as dynamic translation, is compilation done during execution of a program – at run time – rather than prior to execution. Most often this consists of translation to machine code, which is then executed directly, but can also refer to translation to another format.
and From StackOverFlow:
Just-in-time compilation is the conversion of non-native code, for example bytecode, into native code just before it is executed.
I have 4 questions:
1) It's always said JIT=runtime, why doesn't an Interpreter work at runtime? Doesn't an Interpreter translate and execute each line at runtime, while the program is running?
2) It's always said JIT translates a non-native code to native-code, so what? Doesn't an interpreter convert a code to native code? How can my process execute an instruction if it is not translated to native code? So the interpreter needs to translate the code to native code too.
3) A normal interpreter translates each line when it needs to execute it, while using a JIT compiler each line is translated just before it is executed, so it is aviable in that moment when the line need to be executed. Isn't it?
4) So what are the real differene between an interpreter and a JIT compiler, both executes the program at runtime, both translate from an intermediate language to native code...