The A-Z of Programming Languages: Haskell

Simon Peyton-Jones tells us why he is most proud of Haskell's purity, type system and monads.

Simon Peyton-Jones

Simon Peyton-Jones

So would you have done anything different in the development of Haskell if you had the chance?

That’s a hard one. Of course we could have been cleverer, but even with retrospect, I’m not sure that I can see any major thing that I would have done differently.

And what’s the most interesting program you’ve seen written with Haskell?

That’s an interesting question. At first I was going to say GHC which is the compiler for Haskell. But I think the most interesting one, the one that really made me sit up and take notice, was Conal Elliot’s Functional Reactive Animation, called FRAN. He wrote this paper that burst upon the scene [at ICFP 1997].

What it allowed you to do is to describe graphical animations, so things like a bouncing ball. How do you make a ball bounce on the screen? One way to do it is to write a program that goes round a loop and every time it goes around the loop it figures out whether the ball should be one time step further on. It erases the old picture of the ball and draws a new picture. That’s the way most graphics are done one way or another, but it’s certainly hard to get right.

Another way to do it is, instead of repainting the screen, to say here is a value, and that value describes the position of the ball at any time. How can a value do that? Conal’s said ‘just give me a function, and the value I’ll produce will be a function from time to position. If I give you this function you can apply it at any old time and it will tell you where the ball is. So all this business of repainting the screen can be re-delegated to another piece of code, that just says I’m ready to repaint now, so let me reapply this function and that will give me a picture and I’ll draw that.’

In a lazy language, you evaluate expressions only when their value is actually required, not when you call a function - it’s call by need

So from a rather imperative notion of values that evolve over time, it turned it into a purely declarative idea of a value that describes the position of the ball at any time. Based on that simple idea Conal was able to describe lots of beautiful animations and ways of describing dynamics and things moving around and bouncing into one another in a very simple and beautiful way. And I had never thought of that. It expanded my idea of what a value might be.

What was surprising about it was that I didn’t expect that that could be done in that way at all, in fact I had never thought about it. Haskell the language had allowed Conal to think sophisticated thoughts and express them as a programmer, and I thought that was pretty cool. This actually happens quite a lot as Haskell is a very high level programming language, so people that think big thoughts can do big things in it.

Tags a-z of programming languages

More about ISOMicrosoftUniversity of NSWWikipedia




to the editor

Hi there,

how about an iterview on Standard ML?




I'd like to here an interview about new and fast emerging Scala language. It takes a niche in Java world similar to F# in Microsoft world.



Great interview, easy to understand and learned a lot.



Terrific interview! (Hard to go wrong with Simon P.J. -- he's always entertaining. :-)

I'd very interested to see an interview on OCaml, including some discussion to do with OCaml v. Haskell for different applications.


Comments are now closed

Section 313: Federal police used website blocking to tackle malware