I was reading the post written in a blog (post1, post2) where the author compares various languages (Erlang, Python, Ruby, C, JavaScript, Lua, PHP, Common Lisp, Haskell), using a program which computes Pythagorean triplets. I just tried with ActionScript 3 and I'm not able to post any comments in that blog. So I'm writing it here.

import flash.utils.Timer;
 
var t0:int = getTimer();
trace( "result: " + pythag( 5000 ) );
var t1:int = getTimer();
trace( "Elapsed Time (s): " + String( ( t1 - t0 ) / 1000 ) );
 
function pythag( n:int ):int
{
    var a:Number;
    var b:int;
    var c:int;
    var i:int;
 
    for( c=2; c<=5000; c++ ) {
        for( b=1; b < c; b++ ) {
            a = Math.sqrt( c*c - b*b );
            if( Math.floor( a ) == a ) {
                i++;
            }
        }
    }
    return i;
}

Time elapsed is 3.53s. That's fast. Giovanni Intini (the author of that post) was running on a dual core MacBook Pro. I'm running this on a Pentium D dual core. So it must be a fair comparison. So here are the comparison from that site.

Language Time (seconds)
C 0.40
Lua 3.44
ActionScript 3 3.53
Erlang (smp) 3.95
Erlang (non-smp) 5.66
PHP 5 8.9
Python (2.5.1) 11.2
Ruby 12.30
JavaScript (script stopped - taking too much time)