A historical question
peter at engcorp.com
Wed Sep 8 17:59:38 CEST 2004
Carlos Ribeiro wrote:
> On Wed, 08 Sep 2004 14:20:40 -0700, Jerald <jfj at freemail.gr> wrote:
>>I'd like to know when python started working with bytecode.
>>It seems natural that in the first python implementations
>>code was really interpreted : executed directly.
> I assume that you expect direct execution to be the easiest way to
> start implementing a new language. However, that's far from true. It's
> actually pretty difficult to execut programs in procedural languages
> *without* some form of intermediate code, and almost all computer
> languages are compiled at some level before execution. The only
> situation where direct execution makes sense is in the case of simple
> command line interfaces; some simple shell script languages may be
> still executed this way, but that's an exception to the rule. Even old
> languages such as BASIC used to be compiled to some form of
> intermediate code -- a similar concept to Python's bytecode, but much
This is not, as far as I know, true. At least, not for the
general case, although certain specific implementations of
BASIC may have worked this way.
If you are thinking, for example, of how the early BASICs
on things like the Apple ][ and the PET computers worked,
you are misinterpreting (no pun intended) what actually
The only "compilation" that went on was actually called
"tokenization", and that meant only that keywords such
as PRINT were turned into single-byte values that corresponded
directly to the keyword in the source. The rest of the
source was left as-is, including the quotation marks around
strings, variable names, etc. I think whitespace was
generally compressed (i.e. multiple spaces in places where it
wasn't syntactically meaningful were turned into one or none)
but this and the tokenization was more for memory conservation
than for anything else.
I guess one could call this "compilation"... I wouldn't.
In fact, I think in general compilation is a process which
is not 100% reversible, whereas tokenization in the form
BASIC did it was (whitespace aside).
More information about the Python-list