Skip to content


JS vs Python

I sorta expected it due to the new V8, Tracemonkey, Nitro, and SquirrelFish engines. But I’m thinking of making a port of ShinyTouch to JS and I was looking into what differences it might end up as.

I have to say I’m really quite suprised. It’s a simple piece of code:

setTimeout(function(){
var start = (new Date).getTime();
var n = 0;
for(var i = 0; i < 10000000; i++){
n += i;
}
var end = (new Date).getTime();
alert(end-start);
},5000)

Just doing a loop a huge number of times and adding some numbers. But the unscientific results are quite amazing:

Python: 2640, 2110, 2000, 2190

Firefox 3.0 Spidermonkey: 777, 672, 685, 665

Firefox 3.5 TraceMonkey: 659, 365, 629, 629

Chromium Nightly: 146, 150, 147, 152

While these only test basic arithmetic and recursion, The browser is 15 times faster than Python, it just feels quite incredable.

Posted in Uncategorized.

Tagged with , , , , .


5 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. lrbabe says

    I’d be interested to see the performances of V8 compared to another famous virtual machine: the JVM.

  2. admin too lazy to login says

    That would be quite interesting, but JVM would probably be faster.

  3. josep_ssv says

    Me gusta mucho!!.
    Artificial vision
    He experimentado
    http://aamap.110mb.com/graficos/canvas/canvas05.htm

  4. admin says

    Cool1

  5. Anonymous says

    you ever try adding -O when you execute you rpython scripts to use just in time compilation? makes a huge difference depending on what your doing.



Some HTML is OK

or, reply to this post via trackback.