Why Functional Programming Matters?
Understand why every software engineer should definitely learn functional programming.
We'll cover the following
Are you a professional software engineer or aspire to become one? If yes, functional programming is undoubtedly among the most valuable skills to learn. This lesson will show why every software engineer should learn functional programming and why the best time to start is today.
Powerful problem-solving tool
Learning functional programming means you acquire a new tool to solve problems. As with any craftsmanship, the more tools you have mastered and have at your disposal, the more skillful you become. In his insightful essay Teach Yourself Programming in Ten Years, Peter Norvig recommends aspiring software engineers to “learn at least a half dozen programming languages. Include … one [language] that emphasizes functional abstraction (like Lisp or ML or Haskell)”. Both programming languages used in this course, OCaml and Haskell, are ML languages that emphasize functional abstraction.
Functional programming is a great tool to master because it can elegantly solve many programming problems in various domains. For instance, functional programming excels at applications that deal with hierarchical structures such as JSON and XML. Functional programming is also well suited to data processing in mobile apps, web apps, or backend services, especially when filtering, transforming, and aggregating data.
Even if we don’t use functional programming in our day-to-day work, we still hugely benefit from learning it. Functional programming focuses on composition, or building complex programs from simpler ones, as well as on abstraction, or defining highly reusable general functions capturing common computation patterns. These are vital techniques for managing complexity when structuring code and building large software systems. As a result, learning the functional programming paradigm sharpens our ability to design software and write clean reusable code.
The trend towards the declarative paradigm
The software industry has witnessed a gradual shift towards functional programming in recent years. Non-functional mainstream programming languages, such as Java, keep introducing features to write functional code. New programming languages, such as Elm, Elixir, Scala, Swift, and Kotlin, support functional programming from the ground up. Furthermore, more and more frameworks and libraries are heavily based on the functional programming paradigm, such as ReactiveX and Akka Streams. This implies that there is an increasing demand for software engineers with functional programming skills.
Interestingly, the trend towards functional programming is just a part of an overall transition from the imperative to the declarative paradigm in the software industry. Some of them are declarative UI, declarative build systems, declarative build pipelines, and even declarative deployment infrastructure.
Take build systems, for instance. The two most popular build systems today, Maven and Gradle, follow the declarative approach. We tell the system what we want to achieve, and the build system will figure out how to actually do it. This contrasts with imperative build systems like Ant, where we explicitly specify how the system should perform the build by listing an ordered sequence of the statements or commands.
Declarative build systems have many advantages compared to imperative ones. In particular, they allow us to define a build system on a high level without caring about the implementation details. Moreover, they make it easier to create a complex build system from smaller build steps. The same can be said about declarative approaches for UI and infrastructure as code and so on.
Learning functional programming is an excellent way to adopt declarative thinking. It helps us see through many programming languages, frameworks, libraries, and build and deployment tools used in the software industry.
A new way of thinking
If you’ve never done functional programming before, some of the concepts and techniques in this course might feel awkward at first. This is totally normal, even expected. After all, you are acquiring a new way of thinking! As the computer scientist Alan Perlis puts it, “A language that doesn’t affect the way you think about programming is not worth knowing.” Regardless of your current level, this course is guaranteed to affect how you think about programming and make you a better software engineer.