Jay West wrote:
Nah, it wasn't. It's just that (as has been
pointed out here), pseudo
code that is well designed can sometimes be executed in less
instructions than a compiler generates for the equivalent task.
Jay
Intuitively I still can't wrap my head around that. I don't want to
drag the discussion out, but it would seem to me that if the interpreter
had a better way of doing something, then the compiler/runtime should be
able to implement that same method. And thus it becomes a comparison in
implementations, one more optimal than the other. And there is no way
to reconcile that.
The only time I can see an interpreter having a clear advantage is when
it knows something about the runtime environment that the compiler and
it's runtime can't know. Modern Java JIT compiler interpreters do this.
But in a straight up interpreter vs. a compiler and it's runtime
comparison, it's hard to imagine how a reasonable compiler would lose
except for specific implementation problems.
I'll exclude the stack machines from my head wrapping problem until I
get more experience with them.
Mike