I have gone through lot of explanations about a compiler and interpreter. I think I understood the difference between compiler and interpreter clearly. I'll explain my learning through the following example. Let's say we have the three lines of code in a file.
a=3; b=4; a=a+b;
- A compiler converts these three lines into machine code( or into a language which is lower than current language) and processor (if it's machine code) runs it to produce output.
- An interpreter goes through each line, as in it first processes a=3 and produces output according to language specifications. Then, it goes to next line and does the same.
What I don't understand is "how can an interpreter produce output of some code, without having the computing components like ALU of a processor?"
My understanding is that any program should be run by a processor in machine code as processor understands only that.
Or does an interpreter store the machine level instructions that should be run for a function in a high level language and asks the processor to run those machine instructions whenever that specific function comes in code of that high level language?