I'm trying to understand the difference between compilers and interpreters.
I understand that a compiler translates a high level language directly into machine code, all in one go, seeing the entire code.
And I understand that an interpreter - rather than translating into machine code - it directly executes the commands, one at a time.
What I don't understand is how the interpreter does this? Doesn't it also end up having to produce machine code in order to do the execution?
So my question is - aren't compilers and interpreters both producing machine code, while the interpreter is just going the extra step and executing it, line by line (and then discarding the executed machine code)?