Scala vs. JavaScript Performance for BBP

Basically I have an implementation of the BBP algorithm to calculate arbitrary hex digits of Pi. Thanks to this blog post I was able to write a version in Scala, and then another version in JavaScript.

I modified the algorithm to split the calculation into equal sizes (2,500,000 loop iterations). You can look at both versions here.

I was quite surprised when I did a first test run on node.js (v0.10.7). The JS version was just a few seconds behind the Scala version per task. What I expected was an order of magnitude, not just a bit.

The tests look like this and are generated by the Scala version (with the Scala time filled in).