> What if you leave out the j=1?
>
> (i.e., just test an empty repeat loop)
>
> The test given could equally be proving only that the command "j=1" is
> 100 times slower in lingo than VC++.

j=1 probably is 100 times slower in Lingo than in a compiled language.
That's what makes loops slow in an interpreted language.

Here's my take, from 25 years behind the wheel. There are 10 kinds of
people: those who know binary, and those who don't.

Oops, sidetracked by lame humor. There are three levels of code execution:
  - fastest: machine code, which the computer executes directly. C++,
assembler, C, most flavors of Pascal, Fortran--they all convert your source
code to binary machine code.

  - middle speed: bytecode, such as Lingo produces. Director reads your text
source code and converts it into 32-bit tokens, which is then read by the
run-time engine on PC or Mac (sometimes called a "virtual machine").
Variables, operators, functions--they all get converted to this 32-bit
token. A good middle ground where cross-platform development is more
important than speed.

  - slow as hell: directly interpreted source code. The runtime engine reads
the source code directly and figures out how to execute it. You pay a
penalty for having long variable and function names. It takes the machine
longer to parse "x = x + 1" than "myLongVariableName = myLongVariableName +
1". Early Applesoft Basic had a 2-character limit on variable names, largely
for this reason.

So, why do loops run slower in Lingo? Each time through the loop, the
machine has to grab the token and decide what to do with it, then call a
subroutine (probably in machine language) to execute the instruction or
fetch the variable. Machine language cuts out this middle step.

In the real world, most loops are more complex than j = j + 1. With multiple
instructions in the loop, you would find that Lingo runs as much as 400
times slower than true compiled code.

Of course, to balance that we have a very finely-tuned runtime engine that
is optimized for what we do: graphics and animation. If you really know how
to use it, you can do some remarkable things with it. We're getting over 100
fps with our engine on a moderately fast machine (2+ GHz P4), and it's doing
some pretty complex animations.

Cordially,

Kerry Thompson


[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
lingo-l@penworks.com  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to