Sunday, September 22, 2013

STM: F# vs Haskell

STM is a very nice parallel programming model used intensively in Haskell and Clojure. There's a F# implementation which can be found in FSharpx library.

Today I'm going to test performance of both the Haskell and the F# STMs. The test is very simple - read a couple TVars, check their equality, then write them back incremented by 1, repeat a million times.

First, the Haskell code:

So, it took about 170 ms. OK, now F#: It took about 1,6 seconds which is an order of magnitude slower than the Haskell result. It's rather frustrating.

Sunday, September 1, 2013

Grouping consecutive integers in F# and Haskell

Let's look at what F# and Haskell can offer us while reimplementing grouping consecutive integers in C# algorithm.



For my current taste, the Haskell version is more readable due to the awesome separate type annotation and to the lovely Erlang-style pattern matching on function arguments.