Scala Performance vs. Haskell

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Scala Performance vs. Haskell

Stefan Matthias Aust
I implemented the Countdown problem solver from in Scala.

Graham Hutton, the autor, said that, on a 1.5 GHz P4 laptop using GHC
5.04.1, the brute force variant of his algorithm took 74 secs to compute
the 780 solutions.  My machine is probably nearly twice as fast and
using JDK 1.6 with option -server, it took 106 secs to compute the result.

The optimized algorithm in Haskell ran for 8 secs while the Scala
version needed 11 secs. The final version in Haskell ran for 0.8 secs
while the Scala version needed only 0.9 secs.

Keeping in mind that my machine adds probably a factor of 2, it is that
bad :)

Because Scala doesn't have lazy evaluation as Haskell has, I cannot
compare the time up to the first result.  This is, where Haskell really
shines, because it doesn't have to create the permutations of all
possible solutions to filter them down but can "stream" that space.


Stefan Matthias Aust