Why should a Java developer learn about functional programming (FP)? After all, hasn’t
functional programming been safely hidden in academia for decades? Isn’t objectoriented
programming (OOP) all we really need? This book explains why functional
programming has become an important tool for the challenges of our time and how
you, a Java developer, can use it to your advantage.
The recent interest in functional programming started as a response to the growing
pervasiveness of concurrency as a way of scaling horizontally, through parallelism.
Multithreaded programming (see, e.g., [Goetz2006]) is difficult to do well and few
developers are good at it. As we’ll see, functional programming offers better strategies
for writing robust, concurrent software.
An example of the greater need for horizontal scalability is the growth of massive data
sets requiring management and analysis, the so-called big data trend. These are data
sets that are too large for traditional database management systems. They require clusters
of computers to store and process the data. Today, it’s not just Google, Yahoo!,
Facebook, and Twitter who work with big data. Many organizations face this challenge.
Once you learn the benefits of functional programming, you find that it improves all
the code you write. When I learned functional programming a few years ago, it reenergized
my enthusiasm for programming. I saw new, exciting ways to approach old
problems. The rigor of functional programming complemented the design and testing
benefits of test-driven development, giving me greater confidence in my work. I learned
functional programming using the Scala programming language [Scala] and co-wrote
a book on Scala with Alex Payne, called Programming Scala (O’Reilly). Scala is a JVM
language, a potential successor to Java, with the goal of bringing object-oriented and
functional programming into one coherent whole. Clojure is the other well-known
functional language on the JVM. It is a Lisp dialect that minimizes the use of OOP in
favor of functional programming. Clojure embodies a powerful vision for how programming
should be done.