Chapter 13. Thinking functionally

 

This chapter covers

  • Why functional programming?
  • What defines functional programming?
  • Declarative programming and referential transparency
  • Guidelines for writing functional-style Java
  • Iteration vs. recursion

You’ve seen the term functional quite frequently throughout this book. By now, you may have some ideas of what being functional entails. Is it about lambdas and first-class functions? Or is it about restricting your right to mutate objects? In which case, what do you achieve from adopting a functional style? In this chapter, we shed light on these questions. We explain what functional programming is and introduce some of its terminology. We first examine the concepts behind functional programming such as side effects, immutability, declarative programming, and referential transparency and relate these to Java 8. In the next chapter, we look more closely at functional programming techniques such as higher-order functions, currying, persistent data structures, lazy lists, pattern matching, and combinators.

13.1. Implementing and maintaining systems

13.2. What’s functional programming?

13.3. Recursion vs. iteration

13.4. Summary