Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!bloom-beacon!spdcc!ima!esegue!compilers-sender
From: sra@ecs.southampton.ac.uk (Stephen Adams)
Newsgroups: comp.compilers
Subject: Re: Compilers For Typeless Languages
Message-ID: <1989Sep27.004256.5024@esegue.segue.boston.ma.us>
Date: 27 Sep 89 00:42:56 GMT
Sender: compilers-sender@esegue.segue.boston.ma.us
Reply-To: Stephen Adams 
Organization: Southampton University Computer Science
Lines: 43
Approved: compilers@esegue.segue.boston.ma.us
In-Reply-To: Will@cup.portal.com's message of 21 Sep 89 05:12:32 GMT

Compilation is figuring out and doing some things at compile time
(once) so that those things don't have to be done (possibly many times)
at run time.

In his list of reasons for compiling a `typeless language' I think
that Will missed the main source of performance benefit from
compilation which is that the interpreter's case analysis is done once
at compile time rather than many times during run-time.  Interpreting
a loop involves interpreting the loop body for each iteration.  Not so
with compiled code.

I would suggest that compilation is worthwhile unless the primitive
operations are all *so* expensive that the interpreter is spending
`all' of the time doing them and `no' time interpreting the program.
I wouldn't write a compiler for a language of arithmetic expressions
like A+B*C of huge matrixes but I would for smaller values like
strings or scalars or (string or scalar)'s .

An interesting technique for writing compilers based on the
interpreter is given on comp.lang.scheme some time ago:

> ... This method may be called (in
> a very loose way) the "threaded code" technique, or enclosing
> everything into a lambda closure. The technique is discussed in
> detail in the following paper:
> 
> 	%A Marc Feeley
> 	%A Guy LaPalme
> 	%T Using Cloures for Code Generation
> 	%J Journal of Computer Languages
> 	%V 12
> 	%N 1
> 	%P 47-66
> 	%I Pergamon Press
> 	%D 1987

Considering the simplicity of their approach the authors report
impressive speedups (which I have verified).
[From Stephen Adams ]
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{spdcc | ima | lotus}!esegue.  Meta-mail to compilers-request@esegue.
Please send responses to the author of the message, not the poster.