- Amazon Student members save an additional 10% on Textbooks with promo code TEXTBOOK10. Enter code TEXTBOOK10 at checkout. Here's how (restrictions apply)
Real-World Functional Programming: With Examples in F# and C# Paperback – Jan 25 2010
Special Offers and Product Promotions
Customers Who Bought This Item Also Bought
No Kindle device required. Download one of the Free Kindle apps to start reading Kindle books on your smartphone, tablet, and computer.
To get the free app, enter your e-mail address or mobile phone number.
About the Author
Tomas Petricek discovered functional programming as a graduate student at Charles University in Prague. He has been a Microsoft C# MVP since 2004 and is one of the most active members in the F# community. In addition to his work with F#, he has been using C# 3.0 in a functional way since the early previews in 2005. He interned with the F# team at Microsoft Research, and he has developed a client/server web framework for F# called F# WebTools. His articles on functional programming in .NET and various other topics can be found at his web site tomasp.net.
Inside This Book(Learn More)
Most Helpful Customer Reviews on Amazon.com (beta)
Since F# lives in .Net, and .Net is inherently object-oriented; it makes sense to understand something of the mapping that takes place behind the scenes when F# code is mapped into the .Net world.
Many of the interesting new features introduced into C# are actually hand-me-downs from FP (functional programming). This includes generics, LINQ, anonymous methods, lambdas, type inference, etc.. Since many programmers need to use C# in the work-a-day world, it makes sense to understand the functional elements of C# by seeing them in a functional language like F#, where they can be seen in their purest (least hobbled) state. Once these concepts are understood, it is then much easier to understand how to wield these tools effectively in C#.
That said, there are also limits to how much functional programming can be done in C# (and how effectively it can be accomplished). This book clearly demarcates the boundaries of what is (and isn't) feasible in C# vis-à-vis functional programming.
One of the things I liked best about this book is the discussion on why functional programming makes code easier to read, write, and verify. This discussion does not appeal to what might be (for many) inaccessible theory (i.e. denotational semantics, category theory, etc.). Instead it is demonstrated in amazingly simple, straightforward ways! This discussion is very effective.
Another facet of this book's approach that I applaud is the demonstration of lambda calculus. Why would a practical book dabble in theory? There's actually a very pragmatic payoff in doing this: functional programming has a lot of underpinnings in lambda calculus. Those that have been exposed to lambda calculus will feel right at home in F#. Those that haven't are likely to feel more "culture shock" when being exposed to concepts like currying and lazy evaluation. Functional programming really does represent a substantially different way of thinking about computation.
This book also features an excellent discussion about design patterns; comparing and contrasting how they are implemented in OOP (object-oriented programming) versus FP. Some classic design patterns in OOP essentially come for free in FP (e.g. the "visitor" pattern).
An example of what I mean by 'verbiage' - on page 156:
....Let's now analyze how it works in some more detail.
6.4.3 Evaluating the example step by step
It can take some time to become confident with high-order functions like these,
especially when they are nested. We're going to examine how the code from the
previous listing by tracing how it runs for a few sample inputs. Moving from the
abstract question "What does this code do in the general case?" to the concrete
question of "What does this code do in this particular situation?" can often help
to clarify matter
This does not actually say anything - it just introduces what it's going to be written after - that you are going to read in any case. This is a page I opened at random - the book is full of this - constantly telling you what you just read and what you are going to read.
On top of this some more advanced stuff like continuations gets short (and not very illuminating) explanations - that is sort of galling in the middle of all this redundant stuff.
It could have been a good 200-300 pages book, instead it is a mediocre 500+ pages ones.
introduces the functional programming paradigm by comparison to more traditional
imperative programming techniques. The first part of the book goes through many
common programming tasks and compares how you would implement them in the C#
programming language and then re-introduces the problem from a functional
perspective using F#. It introduces simple ideas such as recursion and how to
use recursion to simulate many iterative constructs to the idea of higher-order functions, all the while keeping the explanations and examples very clear. The
author also strives to instill good functional design practices in the reader by
introducing different ways to think of functional programs and common design
patterns that can assist in clean implementations.
The second half of the book dives into more advanced functional concepts, such
as lazy evaluation, efficiency, and continuations. It also takes a look at
using functional programming for practical tasks. Overall, this section is more
suited towards someone who understood the majority of the first half of the book, or to someone who is already familiar with functional concepts.
I would recommend this book to newcomers and intermediate programmers who are
looking to learn about or refine their functional programming skills. The
authors do a good job of covering the core material and also introduce a good
amount of advanced material towards the end of the book.
On the other hand, this book should not be your first F# book, even if you know C#, which the authors draw parallels to throughout and very successfully. The reason for this is that often times you can't follow exactly the examples in the book to get snippet of code runnning. This forces you to go and find other sources to complement the sample code in the book to get it to run and solidify your understanding on the topic. You may like or dislike this.
As a first book I like beginning F#, which is indeed a great companion to this book as in this one, you can actually follow the samples in the book and almost always get running code. Plus Beginning F# has great merit on its own. I will do a review on this book soon.
Beyond that, there are other books which complement this one very well, a few of them are:
* F# Wikibook at [...]. This is a great book by awesome princess.
* Professional F# 2.0: I have not read this one entirely, but what I read I liked.
* Programming in Erlang: This one by Joe Armstrong is not F#, but Erlang shares a lot in common with F# in areas like tuples, list comprehensions, pattern matching and the message passing model. So even if it is not F#, reading this one will give you "portable" knowledge on the concepts mentioned.
* Expert F#: Don Syme's book, nuff said.