Beautiful Concurrency – Simon Peyton-Jones

This is a famous paper on concurrency and the benefits of functional programming. It’s obviously no coincidence that I’ve heard of the author in connection with F#.

For me, a beautiful program is one that is so simple and elegant that it obviously has no mistakes, rather than merely having no obvious mistakes

Simon claims that Haskell is the most beautiful language he knows, then introduces it via an example with side-effects, knowing that the result is quite ghastly to a newbie! He points out that

Being explicit about side effects reveals a good deal of useful information. Consider two functions:
f :: Int -> Int
g :: Int -> IO Int
From looking only at their types we can see that f is a pure function: it has no side effects. In contrast, g has side effects, and this is apparent in its type. Each time g is performed it may give a different result.

I got lost in the middle of the Santa example, but I get the sentiment behind the design:

Since there are no programmer-visible locks, the questions of which locks to take, and in which order, simply do not arise. In particular, blocking (retry) and choice (orElse), which are fundamentally non-modular when expressed using locks, are fully modular in STM.

Leave a comment

Filed under Programming

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s