In the last post, I had shown the performance of an options strategy simulator in Python. It runs in about 10 seconds using Psyco and a bit of Cython, and 1.5-2 seconds in C. A complete conversion to Cython makes it run in about 4 seconds.
Well, the obvious next target of curiosity is: how would it run in other languages? I don't have all the free time I used to have, but today I converted the C version to Javascript, while dodging my 2 year-old son's attempts to punch the keyboard :)
I expected an execution time in the order of minutes. But it ran in 8.3 seconds in Mac OS X's Safari, 7.4 seconds in Chrome, and 7.0 seconds in Firefox. (Yes, Firefox 3.5.7 won.) NodeJS made it in 8.2 seconds.
The code is more streamlined and performance-tuned than Python "production" version, because it came from C version, but it still is a very, very good and surprising result. The Javascript interpreters evolved a lot :)
Any suggestions about the next language? Ruby
UPDATE: I ported the test to Ruby. It needed almost 3:30 minutes to run. It is about 1.5x worse than Python because this test is an optimized version, ported from Javascript version -- the original simulation that took 4:40 to run in Python was more general and had a couple gross optimization bugs. Rubinius took 3:00, a bit better.
PHP scored a fair mark: 1:30, running basically the same script as Javascript and Ruby.
But both PHP and Ruby are humiliated by Javascript. I guess there will be a surge in server-side Javascript usage anytime soon? Using the same language in client and server, and still get a performance bonus, why not?