A historical question

Carlos Ribeiro carribeiro at gmail.com
Wed Sep 8 10:22:52 EDT 2004


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
simpler.

You may think that to create a virtual machine or compiler for a new
language is a hard task. But there is a huge body of theorethical
knowledge regarding all the pieces of software required to implement a
new computer language that can be used for this purpose. There is no
need to reinvent the wheel here. Concepts such as language parser,
intermediate code generator, optimizer, etc -- they're all quite old
and well understood. Automatic tools and code generators can be used,
given the language definition, to create a basic compiler for it. Of
course, there are a few areas with hot new advancements, but the
basics are already solidly understood.

The most dificult part is not implementing the basic compiler or
virtual machine. The hardest part is coming up with a clear and
powerful language design. That's where Python really shines.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list