(Note: This is the fourth part of a whitepaper I wrote a couple of years ago which I never had a chance to publish in full.  You’ll find the earlier parts here, here and here.)


The renewed interest in functional programming has been driven by three main factors:

  • A number of successful high profile organisations making significant investments in these languages
  • The efforts by language designers to lower the barrier to migration from existing languages and platforms
  • The incorporation of functional aspects into non-functional languages

High profile success stories

Being able to cite other organisations that have trodden a similar path always helps language adoption efforts. And when those other organisations are high profile, technically innovative and speak publicly about their technology choices, they become an even stronger role model for other organisations considering the same adoption.

Scala @ LinkedIn

LinkedIn is one of the high profile companies that have gone public with their implementation of Scala. From usage of Scala at LinkedIn, Norbert (http://linkd.in/1dbZsB8) was produced. Norbert provides a framework for distributing simple client/server architectures over a clustered environment to produce highly scalable and fault tolerant solutions for high load environments.

Seamless Java integration, easy concurrency through the Actor model and support for code reuse are listed as being the main reasons for the adoption (http://bit.ly/1gENnmY).

Scala @ Twitter

Twitter uses Scala for much of its infrastructure services (with Ruby/Ruby on Rails for the front-end) including queuing, the social graph store, people search functionality and streaming API (http://bit.ly/1cXIXrW). Beyond the Java integration and code reuse benefits, Twitter highlighted ready access to the language developers and “fast, fun and good for long-running processes” as major reasons for adopting Scala. Furthermore, Twitter has re-invested in the Scala community by releasing numerous libraries it has created as open source software (https://github.com/twitter).

Erlang @ Facebook

Facebook uses Erlang for its Facebook Chat feature and the nature of these services play to the strengths of Erlang’s strong concurrency model. Needing to support upwards of 800 million messages per day across 7 million chat channels, Erlang has served Facebook well in providing the basis for a scalable reliable set of services, upon which the JavaScript and PHP front-end is based.

Haskell @ Finance

The Haskell language is a popular choice amongst corporate banking and trading houses with its usage within ABN AMRO, Bank of America, Barclays, Credit Suisse, Deutschebank, Standard Chartered Bank, as well as non-financial industry companies like Google and Intel (http://bit.ly/1fGjqOJ). The problem domains common to these industries lend themselves to solutions expressed in terms of mathematical functions, making them ideally suited to functional languages.

Clojure @ Netflix

After over a year of investigation, Netflix engineers started investing in Clojure (https://speakerdeck.com/daveray/clojure-at-netflix) for both internal and production services. Netflix’s choice was driven primarily by the abstractions Clojure provides as well as the interactive development model available to Clojure developers via the REPL (Read Evaluate Print Loop) utility. The Netflix story shows a progressive increase in investment in terms of where they introduced Clojure: as their confidence grew, so too did the importance and size of the code that was written in Clojure.

Easy migration paths

LinkedIn and Twitter both declared that Scala’s tight Java integration is an important reason for its selection. With Scala, developers can easily drop down into the Java language to call upon either core Java libraries or 3rd party code that already provides valuable functionality.   Beyond ease of integration at the language level, running on top of the Java Virtual Machine (JVM) gives Scala and Clojure developers the benefit of the thousands of person years invested in developing and tuning the JVM. The same benefits are available to programmers using F# on the Microsoft Common Language Runtime (CLR).

Another common attribute of the organisations listed above is their ability to adopt these languages selectively in small areas due to the nature of their architecture. By composing applications of many independently buildable and deployable services, these organisations can choose a range of different implementation languages and need standardize only on the communication mechanism between the services (e.g. Apache Thrift for Facebook and Twitter).

Functional aspects in non functional languages

Also lowering the barrier to entry to functional programming is the prominence of functional concepts in traditionally non-functional languages. Being able to program with higher order functions when working within another dominant paradigm can help soften the blow for developers who are worried about leaping completely into a functional language.

The introduction of lambda expressions to Java 8 (http://bit.ly/1kGXMzg) is the most recent sign of functional programming influencing the evolution of imperative/OO languages, and C# developers have had access to lambda expressions and higher order functions since 2007. The lingua franca of the web, JavaScript, has supported higher order functions since its creation. Many dynamic languages like Ruby allow blocks to be passed to, and returned from, other functions – emulating the behavior of higher order functions found in many functional languages. With blocks, standard list comprehensions (functions that take lists as parameters and return variations on those lists) like map and reduce can be easily implemented.

It’s also important to note that these features have been introduced for practical reasons. The appropriate use of these features will provide considerable benefits around readability and maintainability by reducing the amount of boilerplate code that is needed for many algorithms.