Archive for the ‘FP’ Category

Why I am learning Haskell

November 27th 2007

I saw Simon Peyton-Jones talk on Software Transactional Memory at OSCON and was amazed at how neat it sounded. Taking some ideas from databases to remove some of the pain of multithreaded programming is a great idea. His point that a thread-safe Dequeue is a post-doc publishable result convinced me that something is wrong with the threading models in widespread use, while STM reduces it to an undergrad problem. The maping from the complexity of the problem domain to your code should be sane, if implementing a a simple structure like a dequeue using threads makes the code lots longer and requires a large amount of effort by someone with a doctorate, something is wrong. I love python, but multithreaded programs suffer (at least in the C implementation) because of the global interpretor lock (GIL). So I decided to learn Haskell.

There are (as far as I know) two ways of doing concurrency; shared state and message passing. STM is a neat syntax and smart compiler technology that ultimately uses shared state. See a Java or C# implementation here.

Erlang is becoming increasingly popular and big successes with high availability at Ericsson are compelling real world examples of its use. It uses message passing concurrency and is a nice (mostly) functional language. I am happy with the choice of Haskell though, the syntax seems neat (because of my maths background) and the functional purity enforces functional thinking more than (say) Common Lisp or OCaml. There was a great post today on Planet Haskell on concurrency options in Haskell and I am keen to explore them.

Maybe I will not hack in Haskell full time, but I think some of the ideas will go mainstream (already appearing in Linq and C# from Microsoft, who have bought in a lot of talented folk from the FP world ), but maybe I will.

It fits my mind well so far.

Posted by tom under ComSci & FP & haskell | No Comments »

Mind Bending Stuff

November 1st 2007

I am just getting my head around this (pdf) comment on the problem at the last ICFP Programming Contest , anyone who likes puzzles, compilers and reverse engineering should take a look, I am amazed by how rich this problem was. The ICFP do not specify what counts as “functional”, but OCaml and Haskell usually do very well in the contest. This year a C++ team won it and a perl team came second, after lots of teams abandoned their functional languages. The authors make the point that data structure design/choice is very important (which we all should know I suppose), they recommend Data.sequence in Haskel and I think it is similar to a Rope (sort of tree based string representation that makes concatenation a snip, wikipedia is weak on it but Ruby Quiz mentioned it a few weeks ago)

Posted by tom under ComSci & FP & haskell & OCaml | No Comments »