Functional Programming
Functional programming is a programming paradigm in which we try to bind everything in pure mathematical functions style. It is a declarative type of programming style. Its main focus is on “what to solve” in contrast to an imperative style where the main focus is “how to solve”
— GeeksforGeeks’s definition of Functional Programming
In order to understand Functional Programming we first need to understand the word function.
What is a Function?
In mathematics, a function[note 1] is a binary relation between two sets that associates to each element of the first set exactly one element of the second set.
— Wikipedia’s definition of a Function
In other words, a function is the relationship between inputs and outputs. Whenever we are given set inputs and want to find the output then we would use some sort of function to solve for this. As you would think, there’s many different ways to express this with graphs, tables, words, and etc.
All that matters is that we give the function inputs to return a output.
Functional Programming — Characteristics
The most prominent characteristics of functional programming are as follows
- Functional programming languages are designed on the concept of mathematical functions that use conditional expressions and recursion to perform computation.
- Functional programming supports higher-order functions and lazy evaluation features.
- Functional programming languages don’t support flow Controls like loop statements and conditional statements like If-Else and Switch Statements. They directly use the functions and functional calls.
- Like OOP, functional programming languages support popular concepts such as Abstraction, Encapsulation, Inheritance, and Polymorphism.