On 21 Oct 2006 at 10:07, Jay West wrote:
You wrote...
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.)
In theory, you are right. In practice I believe you're making too much of a
generalization.
It all depends on the language and the work to be performed.
Certainly, "tokenizing" can cut down on scanning time without
affecting program readability, but that's more a form of input
editing than compilation.
If the operations performed by the language are complex or time-
consuming, then the interpretation overhead is just a small portion
of the overall execution time and doesn't matter very much.
For example, given the nature of operations in a language such as
SNOBOL4, I wouldn't expect that the difference between interpretation
and compilation would amount to much.
The point being that there's more to a compiler or interpreter than
the symbol manipulation. Clever run-time routines can make a huge
difference. Consider another common statement, "Native code is
faster than P-code". Maybe not...
Way back when in the 8-bit world, I was on a project to do a
commercial BASIC. We were given free reign of choices, from strict
interpretation to compilation to native machine code.
Given the operations that BASIC programs tended to perform (lots of
floating-point math, string manipulation and I/O) and a requirement
that the run-time be multi-user, we determined that compile-to-
machine-code had no special benefits and would actually be a
detriment (hard to relocate dynamically and lengthy), we used a
incremental compile to a P-code and concentrated on making math and
string operations very efficient.
The vindication came sometime later when we were showing our system
at one of the trade shows (Comdex/ NCC? -- I don't remember) and
Microsoft was demoing their brand-new compiled Basic-80. A bunch of
attendees decided to run benchmarks among the various BASICs. We
blew M$ out of the water--in spite of their compile-to-machine code
approach, their string handling was dreadful.
We actually sold quite a few systems with multitasking (up to 5 way)
on a single 3.5 MHz 8085 running the usual suite of small business
apps, most of which were ported from the MCBA suite for a DG Nova.
Cheers,
Chuck