Chapter 4. Conclusions
Object-Oriented vs. Functional Languages
In this report, we’ve covered a lot of ways in which ideas from functional programming relate to existing object-oriented design principles. These idioms aren’t as different as a lot of people make them out to be. Definitely functional programming emphasizes the power of reuse and composition of behavior through higher-order functions. And there’s no doubt that immutable data structures improve the safety of our code. But these features can be supported in an object-oriented context as well, the common theme being the benefits that be achieved are universal to both approaches. We’re always seeking to write code that is safer and offers more opportunity for composing together behavior in a flexible manner.
Functional programming is about a thought process. It’s not necessarily the case that you need a new language in order to program in a functional style. Some language features often help though. The introduction of lambda expressions in Java 8 makes it a language more suited to functional programming. While object-oriented programming traditionally has been about encapsulating data and behavior together, it is now adding more support for behavior on its own thanks to ideas from functional programming.
Other languages such as Scala or Haskell take functional ideas further. Scala offers a mix of both functional and object-oriented programming facilities, whilst Haskell focuses purely on functional programming. ...