Re: Why are intepreters so slow today

Larry Wall (lwall@netlabs.com)
Sat, 16 Apr 1994 01:01:49 GMT

In article <nagleCoACH4.25p@netcom.com> nagle@netcom.com (John Nagle) writes:
: Lately, I've been looking at interpreters suitable for use as
: extension languages in a control application. I need something that
: can do computation reasonably fast, say no worse than 1/10 of the
: speed of compiled C code. Interpreters have been written in that speed
: range quite often in the past. But when I try a few of the interpreters
: available on the Mac, performance is terrible.
:
: My basic test is to run something equivalent to
:
: int i; double x = 0.0;
: for (i = 0; i < 1000000; i++) x = x + 1.0;
:
: The Smalltalk and Python versions are slower than the C version by factors
: of greater than 1000. This is excessive. LISP interpreters do a bit
: better, but still don't reach 1/10 of C. What interpreters do a decent
: job on computation?

The slowdown factor for Perl 4 is roughly 90-100. Perl 5 (alpha) is
only about 35-50 times slower, depending on how you want to write that
loop. I can get the ratio down to 1/23 if I make the loops count down
instead of up.

Everything is still done in floating point, however. Ask me
again after I've implemented "pragma integer". :-)

An interpreter that specializes in numeric computation really oughta do
considerably better than this. Perl doesn't specialize in numerics.
Neither do Smalltalk or Python, for that matter. You pay a hefty
penalty in these languages just for assuming that the thing on the
stack is a pointer to something interesting.

Larry Wall
lwall@netlabs.com