Why Functional Programming?
Learn about the need for functional programming and its key attributes.
Somehow, functional programming feels like a relatively new concept. This is strange, considering it slightly predates object-oriented programming (OOP). This might be the case OOP largely won out over functional programming. OOP has been the reigning programming model for several decades now. Outside of the academic world, it’s often the one way all code is written.
Managing complex applications
OOP seems old, familiar, and trustworthy. Functional programming is exotic and unknown. At the same time, the ideas behind functional programming are well-suited to our world. It offers a new way to manage the growing complexity of applications. Yes, OOP promised this as well, but most of us have experienced first-hand that OOP only partly fulfilled its promise.
Parallelism
Functional programming is also keen on helping us deal with the parallelism with which other models struggle. This was fine decades ago but is troublesome in an age where every computer, and practically every smartphone, has a multicore CPU.
Functional features in object-oriented languages
Another reason functional programming may feel fresh and new is that more and more object-oriented languages are adding functional features, such as:
- Java 8 gave us
streams
. - Java 14 brings
records
. - Other languages have taken a pragmatic approach and let us pick and mix our styles of coding. Scala has been doing this for a long time. Kotlin is a more recent example.
Functional programming and object-oriented programming
One final reason functional programming may seem new is that it’s rarely employed regularly. You’ve probably read about its potential and how it will change the way we think about code, but back in the real world, recruiters only ask about our experience with OOP.
Furthermore, the languages a company uses are often better suited for writing code in OOP, frustrating our attempts to write beautiful functional code. For example, consider Java and Python. Java is not only very verbose, but it also lacks support for functions as
Note: We can write beautiful applications with object-oriented programming and create unmaintainable programs with functional programming. Both styles have their own advantages and disadvantages. However, functional programming offers several beneficial qualities to make it a valid choice when starting work on a new application.
This course is based on two of the most popular languages. The first is TypeScript. The second, JavaScript, is ubiquitous in the frontend and growing in the backend.