Jay West wrote:
I don't know about the PCjr, but I have definitely
seen some platforms
where an interpreted language was faster in many ways than compiled
code. Most of the ones I saw like that had the BASIC stored in a
stack-oriented pCode which was then run interpretively. One might think
intuitively that compiled code is always faster than interpreted code.
That's simply not true. When writing an interpreter you start seeing
lots of ways to optimize & "cut corners" that aren't immediately
obvious. In addition, it also depends on the underlying architecture of
the machine and how the compiled code is generated.
It wasn't a theoretical environment in this case. It was the Wiki page
for the PCjr, and the discussion page has the trail.
For this discussion the PCjr has the same interpreted BASIC as the IBM
PC. And there is no way on Earth that the interpreted BASIC on an IBM
5150 or PCjr is nearly as fast as compiled BASIC.
In general I don't believe an interpreted language can beat a compiled
language. Interpreting tokens or keywords is just far slower than
compiled code, unless the compiler is severely broken. (Which I
wouldn't call a fair comparison.)
Except for Java VMs using just-in-time compiles (which makes it more of
a compiler with a nice run-time environment), I can't think of any
machine I've ever heard of where compiled was not faster overall. (Not
talking about specific optimization, but rather the whole program.)
Mike