Search And Destroy

Look out honey, ’cause I’m using technology!

Functional Programming as a Testing Tool

Posted by kilfour on August 4, 2009

I’ve been looking into Functional Programming for a while now. The paper ‘Why Functional Programming Matters’ by John Hughes is what got me interested. The problem imperative languages have dealing with multithreading compared to a functional language was an extra motivation (see f.i. Herb Sutter’s paper ‘The Free Lunch is Over’).
Even though I had been unit testing for a while in different languages, doing it in OCaml, which was the functional language I chose to play around with, seemed to be a lot less rewarding than in an imperative language. No side-effects to take into account f.i., so the tests were quite simple.

Last year I decided to look into Haskell. One of the first things i did (after playing around with the out-of-the-box OpenGL support ;-) ) was check out the testing tools. So there’s HUnit, an xUnit family tester. Looked very familiar to OUnit (for OCaml ). Then there’s QuickCheck, and it blew my mind.

And then I came across this very persuasive John Hughes talk.

Since then I’ve played around with the ideas in C# ( which is more and more starting to look like OCaml btw ).
I am convinced that using functional techniques to test (even non-functional) systems is a more productive way of testing than the xUnit pattern I had been using up ’til now.

About these ads

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 )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: