Book Review: F# for Scientists

F# for Scientists (author, publisher, Amazon) is a new book by British author Dr. Jon D. Harrop, who is the principal at Flying Frog Consultancy and a key player in the small-but-growing F# universe. I just finished reading it.

First, a little about my background: I’ve got very little practical exposure to functional programming. I’ve been working with imperative languages (C++, VB, C#) almost exclusively in my 15-year programming career. And no, I don’t consider Func<T,T> to be good experience working in a functional paradigm. I picked up the book because I wanted to learn something new, yet I wanted to avoid the horrid syntax I see in many other pure-functional languages. F# seems like a good segue from C# – even though they aren’t born of the same mother, they both work well in the .NET universe, and the tools are familiar.

About the book. This is an extremely clear and well-written text. Sections are (mostly) brief, and explanations are well thought out. Each chapter builds upon the previous work, and one is never cast adrift without landmarks. These are all hallmarks of a smart author, and excellent editor, or both.

Dr. Harrop obviously brings a lot of expertise to the table. I gather he’s had a long history with OCaml, from which F# took most of its inspiration. In addition to programming expertise, he’s obviously comfortable with scientific applications and a good chunk of the book is specifically focused on these applications (hence the title!). This was useful – it helped to have concrete problems to solve as I worked through the unfamiliar F# syntax. I’m sort of a math-head so the domain is naturally interesting.

What didn’t work for me? Well, in the first place, I would have liked more background, or perhaps a series of different perspectives, on the advantages of functional programming. Recursion is easy in F#. I get that. I would have appreciated a more thorough analysis of the topic, but perhaps that was too far afield from the main theme of the book.

Second, the brevity of the sections worked wonders for clarity, but perhaps worked against comprehension. One of the neat things about functional programming is the subtle elegance of the constructs – it’s not a hit-you-over-the-head, write-programs-when-you’re-hungover type of language. Some of the more slippery concepts deserved a more thorough airing. Pipelining, for one. Composition of functions. More theory on maps and folds. Anonymous functions. Accumulators.

Overall? Very glad to have purchased the book, and I’ll refer back to it often for the clear examples. However, I need to supplement my education with a separate book that fills in the theoretical/perspective gaps I’ve mentioned.