So, let me see if I get this clearly or not.
-
When we say the differences between a compiler and an interpreter is that an interpreter translates high-level instructions into an intermediate form, which it then executes.
[I think the compiler also translate high-level instructions into an intermediate form but at this moment it generate the object code instead of executing it, right?] -
An interpreter reads the source code one instruction or line at a time, converts this line into machine code and executes it.
[The interpreter itself doesn’t convert the code to machine code, it evaluates the instruction (after that had been parsed) using ist own precompiled functons. E.g. Add expression in the high-level language will be evaluated using the interpreter add function which has been previously compiled, right?]
I would agree with the first, although it is not necessarily true that the interpreter is working on one line at a time (it could do optimizations based on knowledge of the whole code).
The second I think is slightly off: the compiler does create “machine code” (which could be byte code, for a JVM). The interpreter executes parts of its own program based on the input (so far same as compiler), which executed parts are performing the computation described in the input (as opposed to performing computation to calculate the needed machine code).
It is possible to blur the lines between the two as a compiler can generate code that will be interpreted at the time of execution (to provide runtime optimization based on factors that are not available at compile time)