Thursday, January 17, 2008

Book review: Expert F#

Expert F#, by Don Syme, Adam Granicz and Antonio Cisternino, Apress

When a new programming language arrives and manages to make an impact, books about it will certainly appear. However, most often the books will be geared to beginners, to people that is either not very experienced in programming or in the programming paradigms embodied by the language. For a experienced programmer, these books stop right when the fun would begin: the advanced stuff, the corners, the details are left out.

Expert F#, as suggested by its title, is not like this: it is aimed at more experienced programmers. The book will not teach you, for instance, what is functional programming or hammer to your head the best ways to use lists, an ubiquitous data structure in functional languages. But it explains how the things work in F#, so that programmers already familiar with other functional languages will have no trouble picking it up. F# also has object-oriented capabilities, which are explained in a chapter, without however going much deep into OO concepts; the book is about the language, not the paradigms.

And it does this well. Roughly half of the book is about the language itself, the other half are examples of applications and how to use some important libraries. As I was already familiar with OCaml and Haskell, I mostly skimmed through chapters 1 to 4, reading more closely from chapters 5 (generic types) and 6 (how objects fit into F#). From chapter 7 (encapsulating and packaging your code) on, the book starts to get really interesting; the next one is about common techniques, and chapter 9 is the best in the first part, explaining language-oriented programming, an area where functional languages really shine.

There are mandatory chapters about Windows Forms (11), Web programming (14) using .NET and data access, including how to use LINQ in F#, but I really liked chapters 12 (working with symbolic representations), and 13 (concurrency and asynchronous workflows). The former includes two cool examples: a symbolic differentiator and a verifier for logic circuits based on BDDs (Binary Decision Diagrams). There are other important and advanced chapters treating topics like interoperation with C and COM, debugging and testing F# programs, and F# library design.

All in all a very good book about the best current functional language to use in the Windows platform. I have two minor quibbles about it, though: the first few chapters about the language really could be made more interesting (although it didn't affect me much, as I only skimmed them) and some of the more exciting new features of F# could be explained in more detail. Specifically, workflows and active patterns. They are quite recent additions to the language, however, and there is some additional material promised to feature in the book's site.

Anyway, I will keep this book nearby when programming in F#. It is this kind of book that you'd want to keep around, even after learning the language.

2 comments:

Anonymous said...

Dude - the book's only been out for about a month, and it's almost 600 pages. How'd you manage to read it all so you could review it?

Oh, I see - you only skimmed the first part. Interesting, you say it's good, but don't cite any reasons why. Maybe you skimmed the whole thing. Or maybe you mean the table of contents is good.

Let me point out that some people are going to but this book based on your review, and if you actually didn't read it, you are making them waste their $70, and more importantly, their time.

The title of the book is not "F# for Ocaml Programmers", and it isn't "F# for People who are Already Experts". It's for people who want to *become* experts, and if you read the section 'Who this book is for', you would have seen that it claims to be for people who are working with C++, C#, Java and VB.

So, let me remind you that a book is good not if it reads like a stream of consciousness between two experts at a conference. A book is good based on whether it can explain the concepts to people who don't already know them. You might think the first definition was appropriate if your mindset was that of someone who read the book as a self-congratulatory essay on how great you are for already knowing the topic.

Since I'm actually reading the book and not just skimming it, I can't say what the later chapters are like. But if the same level of errors and cryptic description applies to the later chapters as to the early chapters, I'd bet the later chapters need to be worked over too.

Let's describe this book for what it really is: a tome that was rushed out early so some documentation would be available for early adopters.

It's one of the few books available, but truly good books haven't been published yet. Thos are the books that are going to actually do a good job explaining the topic, and they are going to be written by people whose expertise is explaining topics, not by the language authors, who are such experts in the topic that they can't remember what it was like to need important concepts explained to them.

Read this book if you *already* understand the concepts it claims to be explaining, and if you need a good ego boost. Or if you like a good tautology.

And post a positive review only if you've read the book thoroughly.

tautologico said...

Dear Disgruntled Anonymous,

A pretty basic fact about reviews is that they depend on the reviewer -- his tastes, experiences and background will influence how he perceives the work. That's why it is common for reviewers to state their background somewhere in the review, which I did. Functional programming was not new to me, and I already had experience with Haskell and OCaml (which shares a core language with F#, so I already knew its basics). From my point of view it is a good book, that expanded my knowledge of F# exactly where I needed.

As for your ridiculous and cowardly accusations that I hadn't read the book, I must assume it was either malice or that you read really slow. Suppose a person sets aside only 2 hours a day to read the book. Now, 2 hours isn't that much, is it? After 30 days, this person would have spent 60 hours with the book, which for a book of about 600 pages means he would have read only 10 pages an hour. That's not super-human or even extraordinary.