Real world functional programming

The first time I heard something concrete about functional programming was few years ago at a talk in Prague given by Tomáš Petříček. He also mentioned his book Real world functional programming there. It all sounded quite interesting and I told myself that I would look at the book at some time. It took quite a while but I finally found some time and I can know share my impression from the reading.

The title (Real world functional programming) and subtitle (With examples in F# and C#) indicate quite clearly what can be found inside. It is a book about functional programming in general, not really a textbook for a particular language, and it’s more about practical application than about too in-depth theory. Examples are in two .NET languages – functional F# and object-oriented C# and many examples are in both languages, which allows direct comparison of the approaches. And as I mentioned C#, I mustn’t leave out the co-author of the book – Jon Skeet (author of C# in Depth).

I reached for a book about functional programming for two main reasons – firstly I wanted to learn more about “functional philosophy” and secondly to better understand functional features of C#. And I think that’s exactly what Real world functional programming deal with very well.

C# contains many features inspired by functional languages, which require rather different way of thinking comparing to classic object-oriented programming, and C# is also being infiltrated by functional terminology. I remember learning LINQ and being slightly overwhelmed by all the terms (new for me at that time) like lambda calculus, closures and so on. Although it would surely have helped me then if I knew more about functional programming, Real world functional programming has likely higher value for me now when I’m able to make comparison with the implementation in C#.

What did I learn from the book?

Mainly I’ve got a more concrete idea about what functional programming really is, what methods it uses and what advantages it brings. Although I have currently no ambitions to start programming in any functional language, many things are applicable elsewhere – something is rather about a way of thinking, something can be used because even primarily object-oriented languages now include functional features (it’s not just C# or VB.NET, but also Java, for example).

Finally I’m able to imagine how it’s possible to practically program with immutable types.

I discovered elegance of functional programming – some of the presented solutions are simply cool. And all those partial function applications, function compositions, recursive type definitions including infinite series etc. incidentally reminded me that functional programming has an intimate relation to math.

We can expect to meet functional ideas in future even more than today. For example – although it is not addressed in the book (due to its publishing year), it’s obvious that the support for async/await in.NET 4.5 has a lot of in common with asynchronous workflows described in the book. In short, functional techniques has a lot to offer and designers of current object-oriented languages are aware of it.

Leave a Reply

Your email address will not be published.