Functional programming

01 February 2015

Functional programming is on the rise. New languages are constantly being developed and an increasing number of technology companies, start-ups and trading companies are buying into the trend. I went to PyCon last year where I attended a talk by Ian Oszvald in which he discussed functional programming. Ian is co-author of a book titled “High Performance Python” which details how to locate performance bottlenecks and significantly speed up python code in high-data-volume programs. Functional programming supports this very well and high performance Python is often used alongside a functional language where speed is key.

Disclaimer: I am not a Software Engineer or a technologist, but Ian Oszvald’s talk sparked my interest so I decided to investigate further. Functional programming has certainly gained in prominence and popularity and a number of tech giants are increasingly using it and more are adopting it. Functional programming concepts are increasingly being used in many traditional languages. Thus, functional programming may well be altering the employment landscape and experience with functional programming is likely to become ever more valuable in marketing oneself to the leading companies.

Who is using functional programming?

1. Twitter – Scala

2. The Guardian – Scala

3. Amazon – Clojure

4. Facebook – Haskell

5. Whatsapp – Erlang

6. Facebook – Haskell and OCaml

7. Standard Chartered – Haskell

So, what is the reason behind the rise in functional programming?

First things first, what is functional programming? Functional programming is a paradigm which concentrates on computing results rather than on performing actions. When you call a function, the effect of that function is to compute a value and return it. Pure functional programming languages, like Haskell, do not allow reassignment, so variables never change. Although it should be noted that impure languages, like ML, do allow reassignment, so this does not always hold. But functional programming languages differ from imperative languages in how they limit side effects as they can divide a program into pure functions and then separate the side effects. In some languages, like Haskell, you can only do side effects under certain conditions – so called dreaded monads. Since functional programming languages explicitly control side effects they essentially making things simpler. This eliminates a major source of bugs and makes the order of execution irrelevant, thus making parallelization easier. Functional programming is therefore prominent in high performance environments.

One of the main areas of academic research is parallel and concurrent programming. Parallelism is used to make programs faster and concurrency is used to make programs more usable. Processing power on a single processor has peaked and thus there have been a rise in multicore CPUs. Because data structures in pure functional programming are immutable, you don’t have to worry about interaction problems between multiple threads of control trying to change the same data. Thus, functional programming lends itself well to concurrent or parallel programming that takes advantage of multicore CPUs and distributed computing. This is perhaps one of the biggest advantages of functional programming, as concurrency and parallelism are arguably the future of programming. Functional programming supports this well, therefore we are likely see functional programming playing an increasingly prominent role in software development.

While execution speed used to be of great importance, and this is where functional programming fell down, nowadays maintainability, robustness and scalability are generally the primary concern and functional programming excels in these dimensions. As software becomes more and more complex, it’s ever more important to structure it well. Conventional languages place conceptual limits on the way problems can be modularised, whereas functional programming languages overcome these limits. Languages like Haskell use lazy evaluating i.e. delaying the evaluation of an expression until its value is needed, therefore allowing performance increases by avoiding needless calculations. Higher order functions and lazy evaluation can contribute significantly to modularity, a technique that emphasizes separating functionality of a program into independent modules. Since modularity is the key to successful programming, functional languages are vitally important to the real world.

Finally, another contributing factor to the rise of functional programming has been the rise of Big Data. Functional programming languages are particularly valuable in big data computing as they are excellent in data processing. For example, Google MapReduce processing is very natural and almost trivial to express in any functional programming language. Many kinds of data processing fit well with functional programming, hence the popularity of Clojure and Scala in those areas.

So where does that leave you?

As an OO software developer, you might be interested in exploring functional programming in the interest of keeping abreast of new developments and improving your skills. While many functional programming techniques and features are still locked in functional languages (especially Haskell), some others have already filtered through to more popular multiparadigm languages, from Scala, to C# to C++. Many imperative languages are taking concepts from functional programming languages, but actually thinking functionally is an acquired taste. Picking up Scala, Clojure or F# is a good start. F# is used by many banks and may be particularly useful to you if you work within the .Net framework. You can use ideas you’ve learned to write cleaner, more concise code in more traditional languages you’re already using. A strong command of a functional programming language is by no means a prerequisite to get a job as a functional programming engineer, but as functional programming gains in popularity it will be increasingly advantageous to develop your skills and gain experience.

This article is a work in progress. Your comments are welcomed and appreciated. Please address all thoughts to

View all blog posts