Key Concepts/Terms of Functional Programming
The following concepts are major and important concepts of Functional Programming.
- First-Class Functions.
- Lazy Evaluation.
- Higher-Order Functions.
- Immutability(Non-Mutable Data).
- Modularity.
- No Side-effects.
- Lazy Evaluation.
- Recursive Function-Calls.
Imperative Programming ( IP )Core Concepts
-
Sequence of Statements.
-
Order of execution of Statements is very important.
-
They contain state.
-
They use both Immutable and Mutable Data.
-
They can change state.
-
They may have Side-effects.
-
Stateful Programming Model.
-
They directly change the state of Program.
-
They represent state with Data Fields.
- Sequence of Statements.
- Order of execution of Statements is very important.
- They contain state.
- They use both Immutable and Mutable Data.
- They can change state.
- They may have Side-effects.
- Stateful Programming Model.
- They directly change the state of Program.
- They represent state with Data Fields.
Functional Programming vs. Object-oriented Programming
Functional Programming | OOP |
---|---|
Uses Immutable data. | Uses Mutable data. |
Follows Declarative Programming Model. | Follows Imperative Programming Model. |
Focus is on: “What you are doing” | Focus is on “How you are doing” |
Supports Parallel Programming | Not suitable for Parallel Programming |
Its functions have no-side effects | Its methods can produce serious side effects. |
Flow Control is done using function calls & function calls with recursion | Flow control is done using loops and conditional statements. |
It uses "Recursion" concept to iterate Collection Data. | It uses "Loop" concept to iterate Collection Data. For example: For-each loop in Java |
Execution order of statements is not so important. | Execution order of statements is very important. |
Supports both "Abstraction over Data" and "Abstraction over Behavior". | Supports only "Abstraction over Data". |