On 18 Nov 2003 18:38:09 GMT, Joona I Palaste <
[email protected]>
wrote:
Hmm, there are several things that can be done in an interpreter that
can't be done in a compiler. <snip>
Are there any things compilers can do that interpreters can't? I'm
fairly sure there are things compilers can do *easier* than
interpreters, but is there any that compilers can do and interpreters
can't do *at all*?
Actually I would say any given functionality that can be implemented
both places is easier, or at least simpler, in an interpreter, since
it has strictly more information available about the program(s).
Compiled code almost always runs faster than interpreted, usually much
faster; this is a difference of degree rather than kind, although it
may have a qualitative effect -- classic number-crunching example: if
it takes 1.5 days to run a 1-day weather prediction it's useless, but
0.5 days becomes valuable. More generally, the interpreter also has
some overhead for things like file opens and buffers, etc., so at the
margins on a given machine compiled code can run problems/inputs
slightly larger by various measures than interpreted. OTOH on most
architectures compiled code is larger than source, so an interpreter
can probably load (at all, or with less swapping) a larger program.
(Although I guess you could claim conversely that compiled code
exercises VM/swapping mechanisms more extensively. <G>)
A compiler can in most cases, unless deliberately restricted by
licensing or configuration, produce a program that runs on another
machine or many other machines (without special software installed)
and for a cross-compiler even on a different type of machine. Compiled
code can be distributed without source, which except for obfuscated or
just really awful source makes it significantly harder though not
impossible to read and/or understand.
You can usually combine object code compiled from multiple languages
into a single executable, while it is at least very hard for two or
more interpreters to work together so closely; a single interpreter
can usually(?) call (pre)compiled code from other languages, but it is
often(?) more difficult to provide an interpreted entry or callback
that can be called *from* other-language code.
Should I ask at comp.programming?
Don't know.
- David.Thompson1 at worldnet.att.net