Compiling vs interpreting [was Re: A certainl part of an if() structure never gets executed.]

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Jun 16 08:07:21 EDT 2013


On Sun, 16 Jun 2013 10:51:31 +0000, Denis McMahon wrote:

> On Sun, 16 Jun 2013 12:59:00 +0300, Nick the Gr33k wrote:
> 
>> Whats the difference of "interpreting " to "compiling" ?
> 
> OK, I give up!

Actually, that's a more subtle question than most people think. Python, 
for example, is a compiled language. (What did you think the "c" in 
".pyc" files stood for? and the compile() function>?) It is compiled to 
byte-code, which runs on a virtual machine, rather than machine-code, 
which runs on a physical machine. Except PyPy, which *is* compiled to 
machine-code. Except that it doesn't do so at compile time, but on the 
fly at run-time.

And these days, for many types of hardware, even machine-code is often 
interpreted by a virtual machine on a chip. And even languages which 
compile to machine-code often use an intermediate platform-independent 
form rather than targeting pure machine-code. The line between compilers 
and interpreters is quite fuzzy.

Probably the best definition I've seen for the difference between a 
modern compiler and interpreter is this one:

"...the distinguishing feature of interpreted languages is not that they 
are not compiled, but that the compiler is part of the language runtime 
and that, therefore, it is possible (and easy) to execute code generated 
on the fly."
-- Roberto Ierusalimschy, "Programming In Lua", 2nd Edition, p. 63



-- 
Steven



More information about the Python-list mailing list