Functional Programming: Available Chapter Excerpts & Discount

The work on my book Functional Programming for the Real World is slowly getting to the end. I'm currently creating index for the last couple of chapters and doing final updates based on the feedback from reviews and also from the forum at (this means that if you have some suggestions, it's the best time to post them - I haven't yet replied to all of them, but I'll certainly do that before the manuscript will go to the production).

Look Inside the Book

If you want to look inside the book, you can read the first chapter, which is available from Manning (a slightly updated version of the chapter should be available soon). However, there are other parts of the book available for free. Manning occasionally publishes chapter excerpts (that is some relatively stand-alone part of a chapter) as articles on various programming web sites. Since I haven't posted a link to any of them on the blog, here they are. The first two chapters has changed quite a lot since the article was published, so you won't find much from the first article in the book. However the last two are still there:

  • Declarative Programming Style

    Published October 10, 2008 at CodeGuru (from Chapter 2)

    In this article, I'll talk about two properties of functional languages that together define the overall style of writing functional code. Most of the examples will be implemented in C# using the new C# 3.0 functional features, however you'll also see an example in F#. In many functional languages every language construct is an expression. The languages try to minimize the number of built-in concepts and are very succinct and extensible. We'll see that basic building blocks implemented in a functional language use recursion. However, writing every operation explicitly using recursion would be difficult, so we'll look how to write a single function that can be used in many variations for different purposes. These two concepts together define what a declarative programming style is, so after discussing them, we'll talk about the benefits of this style.

    Read the article...

  • Immutable Data Structures in C# and F#

    Published February 6, 2009 at CodeProject (from Chapter 3)

    In this article we'll take a look at one of the several concepts that together form the 'functional programming' paradigm. You probably noticed that the term functional programming has appeared in many areas recently - the C# 3.0 and LINQ have been largely influenced by this paradigm and many of the libraries that enable and simplify writing parallel code rely on functional ideas. Microsoft also recently announced that Visual Studio 2010 will include F# - a functional language - out of the box.

    The functional paradigm is based on different principles than the imperative style. You may know some of the concepts already - for example 'anonymous functions' from C# 3.0 give us the ability to use function as an argument to a method. In functional programming, the ability to write functions that take other functions as an argument or return them as a result is one of the basic principles.

    Read the article...

  • Tracking Dependencies and Side-Effects Using Immutability

    Published July 7, 2009 at CodeProject (from Chapter 11)

    Using immutable data structures has many benefits. Perhaps the most discussed benefit is that immutability makes it easier to parallelize the program. When all the data is immutable, we can safely access them from multiple threads and there is no danger of race conditions, because none of the threads can modify the shared state. You can find more information about parallelization in chapter 14, but this is not the only consequence of immutability...

    The benefit that we'll discuss in this article is that immutability provides great clarity to your code and you can use it to better understand what code does. If a function takes a list as an argument and returns a number, you can safely assume that it calculates the result based on the list content, but does not modify the list. We don't have to look at any code to reach that conclusion; we don't have to examine the implementation or any other functions that it calls. Let's start by looking at an example that demonstrates how easy it is to introduce errors when using mutable objects.

    Read the article...

Buy "Functional Programming" with 30% Discount

If you're considering buying the book, you can get it from Manning right now (even though it isn't completed yet) thanks to the MEAP program. You'll get PDF with the current manuscript and a final version (including printed book if you want) when it'll be done. The last excerpt published at CodeProject also includes a 30% discount code that you can use at check-out. The book is also available at Amazon (UK, USA), but in that case you'll have to wait for the final printed version (estimated for October).

Discuss on twitter, .
Send corrections via GitHub pull requests.