2 Replies Latest reply on Aug 4, 2008 5:23 PM by Newsgroup_User

# Is Director's Lingo faster than Flash's Actionscript?

Back in 2001, Gary Rosenzweig published "Comparing Lingo and ActionScript" over at http://director-online.com/buildArticle.php?id=973

At the time Lingo was 45x faster for a script that finds all of the prime numbers between 1 and 1000. AS code and Lingo were matched line for line in this script:

---------LINGO-------------
on prepareframe
startTime = the milliseconds
repeat with potentialPrime = 1 to 2000
isPrime = TRUE
repeat with i = 2 to potentialPrime-1
n = potentialPrime/i
if n*i = potentialPrime then
isPrime = FALSE
exit repeat
end if
end repeat
end repeat
alert "Total Time: "&(the milliseconds - startTime)
end

//--------------ACTIONSCRIPT----------------
test();
function test() {
startTime = getTimer()
for(potentialPrime=1;potentialPrime<=1000;potentialPrime++) {
isPrime = true;
for(i=2;i<potentialPrime;i++) {
n = int(potentialPrime/i);
if (n*i == potentialPrime) {
isPrime = false;
break;
}
}
}
trace("Total Time: "+(getTimer() - startTime))
}

Rerunning the same test today, comparing MX2004 Lingo with AS2 in FlashPlayer 8, we find the gap significantly closed , but still with Lingo being 6x faster.

Congrats to Flash for a relative 8x speed increase in 7 years. But imagine what we could be achieving with Lingo, if Director had had the same amount of attention from Adobe/Macromedia since 2001!

Anyway, just thought I'd give you some good news. :)
• ###### 1. Is Director's Lingo faster than Flash's Actionscript?
I was also curious about Javascript in Director, so I ran a JS version of the same script:

function test() {
startTime = _system.milliseconds
for(potentialPrime=1;potentialPrime<=1000;potentialPrime++) {
isPrime = true;
for(i=2;i<potentialPrime;i++) {
n = parseInt(potentialPrime/i);
if (n*i == potentialPrime) {
isPrime = false;
break;
}
}
}
trace("Total Time: "+(_system.milliseconds - startTime))
}
test();

Well, it surprised me. And disappointed me too. This came in at 5x slower than the same script in Lingo!
• ###### 2. Re: Is Director's Lingo faster than Flash's   Actionscript?
You have provided some examples of relative speed with Lingo/AS/JS, but
to your original question "Is Director's Lingo faster than Flash's
Actionscript?" I think the answer is "sometimes". For example, it's a
little unfair to compare E4X with XML handling in Director since Lingo
(and JS?) don't have equivalent native commands. Functions provided to
Director by xtras are almost certain to be faster than any AS equivalent
since they likely run in compiled C/C++

Cheers,
Sean (Miranda, NZ)