|
|
Surprisingly (or maybe not) Adobe's ActionScript compiler (which generates the byte-code for Tamarin) itself is actually a Java application.
Here's Tamarin:
function tak(x:Number, y:Number , z:Number) {
return y >= x ? z : tak(tak(x-1, y, z),
tak(y-1, z, x),
tak(z-1, x, y));
}
var i = 0;
while (i < 100) {
tak(24, 16, 8);
i++;
}
$ java -jar asc.jar -import builtin.abc tak.as
$ time ./avmplus tak.abc
real 0m58.587s
user 0m57.900s
sys 0m0.130s
And here's Java:
public class Tak {
public static double tak(double x, double y, double z) {
return y >= x ? z : tak(tak(x-1, y, z),
tak(y-1, z, x),
tak(z-1, x, y));
}
public static void main(String argv[]) {
for (int i = 0; i < 100; i++) {
tak(24, 16, 8);
}
}
}
$ time java -cp . Tak
real 0m2.231s
user 0m2.143s
sys 0m0.061s
Interestingly, I also tried the Mozilla Rhino JavaScript engine (which I contributed to years ago), which is a pure Java implementation of JavaScript with this result:
$ time java -jar js.jar -opt 9 tak.js real 0m31.944s user 0m31.718s sys 0m0.181s