Sunday, 9 November 2008

Why does Functional Programming matter?

Of course we all know the answer...

...but recently I've been wondering how to explain what I feel is important about FP in a pithy, succinct way. (I've frequently found myself failing to explain it well).

I think in the future I'm going to say this:

"Functional Programming makes programs easier to understand. And that means they're less likely to go wrong."
For my money this is why functional programming is vitally important - because the biggest problem we have right now isn't concurrency ... it's the fact that we can't even write single-threaded programs that work properly. (Of course "go wrong" is used above in the standard rather than the Milner sense).

One other comment I'd make is that I think the "easier to understand" bit becomes more apparent with bigger programs.

I'd be interested in hearing if anyone's got a better way of describing it.


2 comments:

Crutcher said...

While this is a fun argument, I don't think its a very convincing one. You've give an unqualified 'easier', which begs the question, 'easier than what?'. No one who doesn't alread agree with you is going to buy that the answer is 'everything'. Indeed, I don't think most FP fans would agree with that either.

Ben said...

Hi crutcher. My aim isn't so much to be convincing - that's going to be tough to do in a sentence or so - as just to summarize my feelings snappily.

As to "easier than what"? - than mainstream imperative / OO programming styles. (Of course it's been claimed that Haskell's a pretty decent imperative language too - but that's probably largely because of the localisation of effects - which is all part of keeping things "understandable").