Functional programming is a declarative programming paradigm that allows you to concentrate on the logic of a computation without describing its control flow. This is in contrast to imperative programming, which uses control statements to describe the flow of programs.
The following diagram represents a simplified classification of programming languages:
Functional programming assumes that the software is constructed based on the following principles:
- Pure functions
- First-class functions
- Higher-order functions
- Function composition
- Typeclasses
- Lambdas
- Closures
- Immutability
The following diagram shows a combination of these concepts:
We'll look at some examples of declarative and imperative styles to get a better understanding. We'll cover all the principles of functional programming just mentioned.