Chapter 1. What is functional programming?

This chapter covers

  • The benefits of functional programming
  • Problems with side effects
  • How referential transparency makes programs safer
  • Reasoning about programs with the substitution model
  • Making the most of abstraction

Not everybody agrees on a definition for functional programming (FP). In general terms, functional programming is a programming paradigm, and it’s about programming with functions. But this doesn’t explain the most important aspect: how FP is different from other paradigms, and what makes it a (potentially) better way to write programs. In his article “Why Functional Programming Matters,” published in 1990, John Hughes writes the following:

Functional programs contain no assignment ...

Get Functional Programming in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.