Types of Programming Pardigms
There are 2 primary categories of programming approaches and most of the programming languages can be broadly classified into one of these categories based on their features and usage model. These two major programming paradigms are as follows:
This type of programming paradigm focuses on the following aspects of programming:
- Given a problem statement, how to efficiently solve the problem. This could be specified as a set of steps that could be executed to find a solution to the problem.
- As a result of the above approach, this programming model results into a well defined set of control flow statements thereby producing a FSM (Finite State Machine).
- This is more commonly used in programming of most real world software and applications.
- Some common examples of programming languages that utilize the imperative programming paradigm are C programming language.
This type of programming paradigm focuses of the following aspects of programming:
- Given a problem statement, it focuses on what to solve instead of how to solve it. This could be specified as a series of mathematical evaluations called in order to extract the desired result from a given set of input.
- This programming paradigm does not employ the specification of a set of ordered steps to achieve the results, and thus lacks a control flow graph as well as well defined states during execution.
- This is less popular due to its complex syntax and need of expertise in the programming language.
- These are usually very efficient in solving a problem and involve lesser code as compared to imperative programming languages.
- Few areas where functional programming is used in real world applications are artifical intelligence and data modeling.
- Some common examples of programming languages that utilize the declarative programming paradigm are Haskell & Scala.
What is Procedural & Functional programming?
This is a subset of imperative programming and is most commonly seen in the modern day languages that are designed to perform imperative programming. As the name suggests, the set of ordered instructions or commands executed to obtain the results can be structured in the form of procedures, hence the term procedural programming.
This is a subset of declarative programming and majority of the modern day declarative programming languages support functional programming. As the name implies, the mathematical evaluations performed to obtain the desired results from a given set of inputs are invoked in the form of function calls that are often pure functions.
Can a programming language be both Imperative & Declarative?
Yes, as a matter of fact, some of the most popular programming languages in the world combine the features and benefits of both Imperative & Declarative programming paradigms. For eg. Both C++ and Python are considered multi-paradigm programming languages because they support features of both Procedural & Functional programming.