TP

Functional Programming in .NET book - An update

Book cover

Recently, I announced on my blog that I’m working on a book for Manning called Real world Functional Programming in .NET. The goal of the book is to explain the most interesting and useful ideas of functional programming to a real world C# developer. I'm writing this book, because I believe that functional programming is becoming increasingly important. Here is a couple of reasons why you should have this book on your bookshelf:

To summarize, the goal of the book is to explain the key ideas of functional programming to real world .NET developers in a way they can benefit from them. It actually very much follows my personal experience – I started seriously looking at functional programming in the F# language after using primarily C# for quite a long time. Anyway, you can read more about the book in my previous post, on the book web site or on the official Manning book page. The book is available via the MEAP (Manning Early Access Program) and if you want to get a better idea what is the book about, you can read the first chapter for free.

What’s new?

It is more than a month since I posted the announcement, so I decided to write a brief update. Manning is making the book available via the MEAP program, which means that if you can buy it right now and you’ll receive an updated electronic version every time a couple of chapters is finished. Once the whole book is completed, you'll get the final version (either electronic or both electronic and printed). Last time I wrote about the book, there were first 4 chapters available. If you buy the book today, you’ll get first 9 chapters. Chapters 8 and 9 were added just this week!

About two weeks ago, the MEAP version of the book was first in the list of Manning bestsellers (even before books on topics like ASP.NET "MVC" and Silverlight, which was a very nice surprise for me)! Click on the image to see the full-size screenshot:

MEAP books

What’s inside?

The most interesting thing for me about writing the book is that I really had to shape my ideas very clearly and find a good way to organize all the topics. One point of view that I found particularly useful (and it reflects how I write code in F#) is that F# gives you a way to start with a very simple, easy to write and clear code and later turn it into a robust .NET code. At the beginning you can write your code just as a script for F# interactive using only the basic functional features. Thanks to the type inference the code is also very succinct. In the later phase you can use features like abstract interface types and object expressions to organize the code and make it easily accessible for example from C#. The nice thing is that the transition is very smooth, so you don't have to rewrite almost any code.

Since many of the functional features are now available in C# 3.0, it is possible to apply some of these ideas to C# too. In particular, we can simplify many object-oriented constructs (including some well known design patterns) and also use many effective functional techniques. This way of thinking is very suitable for a book, because we can start by looking at simple and clear ideas and then learn more sophisticated techniques and language features. The chapters that are currently written follow this organization. Here is a brief overview of the content of every chapter:

Part I. Introduction

To many of the readers, functional programming is a completely new idea. The basic principles of functional programming are also quite different to what you may be used to. The first part of the book (containing chapters 1 - 4) serves as an introduction and touches lightly some of the ideas that will later become essential.

Part II. Core functional techniques

The second part starts describing the "iterative development style" enabled by functional programming in F#. It discusses elementary ways used to construct functional programs. These give us a very clear and concise way to think about problems. Finally, in the later chapters it talks about functional applications from a higher perspective focusing more on architectural acpects.

Part III.

This section focuses on more advanced concepts that are used later in the "iterative development style". Once the application or a library grows larger, we want to use various .NET facilities to organize it intuitively, expose it to other .NET languages and document it. If the library is intended only for F# then we can leverage of some advanced F# features. Finally, we also want to make the code more efficient by using general functional and F# specific optimization techniques.

These are all the chapters that I wrote already (Chapter 10 will be added to the MEAP program in the next update). I'll definitely blog about more chapters as I'll write them, so stay tuned for another update!

Looking for your feedback!

The book is still "work in progress", so I'm very glad to receive any feedback. I already got many useful comments and suggestions via the book forum at Manning, from the reviewers of the first third of the book and also from my colleagues and friends. However, this is probably the first book about functional programming that aims to a very wide audience of .NET programmers, requiring only advanced C# background, so any comments are more than welcome! You can post them to the forum mentioned above as well as directly to me at tomas@tomasp.net.

More information

Published: Monday, 20 October 2008, 10:10 PM
Author: Tomas Petricek
Typos: Send me a pull request!
Tags: functional, c#, universe, web, writing