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.


4 Responses to “Book Review: F# for Scientists”

  1. 1 quantblog September 24, 2008 at 5:20 pm

    Interesting review, Id seen lots of mention of this book, and F# seems to be generating a lot of buzz at the moment.

    I have a lot of respect for Don Syme and F# seems like a nice ocaml dialect for coexisting well with microsoft ecosystem [notably excel in this case]…

    My main concern is whether M$ will kind of kill the language in the journey to commercialize it as a well-supported product.

    I have immense respect for Anders Hejlsberg, architect of the C# architect. Ive was always a die-hard fan of Turbo-Pascal and Delphi.

    I think C# has been very successful in its growth from cool-language to serious development platform.. so M$ managed that well.. so theres hope it will be done with some style, keeping focus on the elegance of the language, rather than the slickness of the tool per se – successful languages tend to be driven by the uncompromising vision of an individual…

    Its always nice to have cross-platform, so Ill be interested to see how mono support goes along for F#. Will people be able to write programs that use common libraries and have them work on both Win and Linux [and OSX!] stable over time of say 5-10 years?

  2. 2 xinyustudio September 24, 2008 at 9:26 pm

    “This is an extremely clear and well-written text”, I have strong reservation. I think this book lacks sufficient rigorousness. When you read it without any prior knowledge about F#, this is rather painful. On the first reading of the introdcution chapter, for instance, I am completely lost, what is “t::h”? I have to google it! In this sense, this book is not self-contained or may be not targeted to newbie users? Or the author assumes the readers to be somehow familiar with F#?

  3. 3 Anthony Stevens September 25, 2008 at 8:43 pm

    @xinyustudio: I see what you mean: the cons pattern (::) is introduced on page 17-18 without any prior explanation. That’s definitely a flaw in the book, but I regard it as a minor one. I’m curious what your prior languages are?

  4. 4 xinyustudio October 16, 2008 at 5:14 am

    This is just an example, while you can see many of such “flaws”, seriously. I have 10+ years C++ and 2+ years C# programming experience. Anyway, I don’t think the readibility of the book is good, quite different from your review.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ 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

TwitterCounter for @anthonyrstevens
Add to Technorati Favorites

RSS Feed

View Anthony Stevens's profile on LinkedIn

%d bloggers like this: