Book review: Real-World Functional Programming

image

I’ve picked up Real-World Functional Programming because I wanted to learn F# and despite numerous attempts on my side I just couldn’t understand it. I understood the F# syntax and I knew how to write applications using F# but I just didn’t get it – I always thought that it was only suited for math majors,  and it seemed like a lot of trouble just to have the same result I can get using C#.

After reading this book I know I was wrong! Now I know two things:

  1. F# can be used to solve real world problems in my domain of work
  2. How my C# code can benefit from functional programming.

Some examples in the book are shown in C#, some in F# and many in both – which help you learn functional programming and not just F#.

The book is divided to four parts form the simplest tutorial (yes - “hello world”) to the most complicated graphic/animation/multi threaded application.

Part 1 Learning to think functionally

This part of the book is an introduction to the world of functional programming. Reading this chapter made something in my mind “clicked” - I finally understood what the whole fuss was about. This chapter has mostly C# examples that look a bit weird at the beginning – (e.g. using readonly (immutable) fields) but by the end of this chapter you might start to consider how to apply these simple ideas to refactor your own code.

The basic F# “types” are introduced namely tuples and lists. The last chapter of this part shows how to integrate the new F# code with the old C# application – on how to call the .NET libraries from your F# code and on using the interactive console as a development tool.

You’ll learn about the benefits of declarative code and state recursion to name a few. By the end of this part you’ll be able to read and write simple F# code and know a lot more about declarative programming than you did before picking up this book.

Part 2 Fundamental functional techniques

This is where the fun begins. After functional programming was explained and you were shown a few simple examples on the first part it’s time to really learn about how to use all of the functional programming goodies.

This chapter starts with building a simple application and improves it by using more advances language features such as using discriminating unions, generic types and lambda expressions.

The last two chapters explains about how to design a data and behavior centric applications.

Part 3 Advanced F# programming techniques

This part shows several unique capabilities of the F# programming language namely .NET integration. The efficiency of data structures is explained along with tips on how to optimize F# code. There is a good chapter on refactoring and testing of functional programs – that could have been a bit more detailed in my opinion. And Linq and Monads are explained.

Part 4 Applied functional programming

This chapter is the one you’ve been looking for when you started to learn about F# and functional programming – Asynchronous operations, parallel programming composite applications and reactive (!) are the topic discussed. This part is all about harnessing the power of functional programming to solve complicated problems in an elegant and simple solutions.

 

Conclusion

Functional programming is not simple nor trivial, Real-World Functional Programming does an excellent job of explaining what its all about.

Real-World Functional Programming teaches a paradigm using a functional language and not the other way around. There are better books to learn all of the ins and outs of F# but it would be just like reading a book on C# without understanding OOP (Object Oriented Programming).

 

So if you’re a software developer that’s looking how to improve your ability – even if you’re not interested in F#, hack even if you’re not even a .NET developer – read this book!



Labels: , , ,