Showing posts from August, 2013

Haskell: performance

It turned out that it's not Haskell who was slow in my previous Fibonacci test. It was my lack of Haskell knowledge. Haskell has two integral types - Int, which has bounds -2147483648..2147483647 and Integer, which is unbounded. Both types implement Integral type class, so out fib function can be defined in terms of this type class:
OK, now we can test performance of the function parametrizing it with the two concrete types. Integer first:
We get our previous result ~15 seconds which is rather slow. Now test it with Int type:
Whoa! The Int type is ~6 times faster than Integer! And with result of 2.8 seconds Haskell's took the third position in our small rating :) Current list (in seconds):
C# - 1.26F# - 1.38Nemerle - 1.45Haskell - 2.8Clojure - 9Erlang - 17 Ruby - 60 Python - 120

Beginning Haskell

Okey, it passed about a year I started learn and use F# and it's now time to learn Haskell. As usual, I started from the naive Fibonacci function: The performance in this particular algorithm is not fantastic, it's actually ~4 times slower than F#. It's OK for now.