PROGRAMMING PARADIGMS
The term programming paradigm refers to a style of programming. It does not refer to a specific
language, but rather it refers to the way you program. There are two main categories of
paradigms:
A. Imperative programming paradigm:
It is one of the oldest programming paradigm. It is a programing paradigm in which the
programmer instructs the machine how to change its state through program statements. It
performs step by step task by changing state. The main focus is on how to achieve the
goal. The paradigm consists of several statements and after execution, the result is stored.
It’s about writing a list of instructions to tell the computer what to do in a step by step
manner. Imperative programming is divided into three broad categories: Procedural,
Object Oriented Programming and parallel processing.
Advantage:
Very simple to implement
It contains loops, variables etc.
Disadvantage:
Complex problem cannot be solved
Less efficient and less productive
Parallel programming is not possible
The following fall under imperative programming:
a. Procedural programming: This paradigm groups instructions into procedures. There is
no difference in between procedural and imperative approach. It has the ability to
reuse the code and has been made popular based on its reusability. Examples of
programming languages using this paradigm are: C, Pascal, Fortran etc.
b. Object oriented programming: This paradigm group instruction into objects which
are meant for communication. The objects communicate by performing operations
called methods. The smallest and basic entity is object and all kind of computation is
performed on the objects only. More emphasis is on data rather procedure. It can
handle almost all kind of real life problems which are today in scenario. Example of
programming languages include: C++, java, Perl etc.
Advantages:
Data security
Inheritance
Code reusability
Flexible and abstraction is also present
B. Declarative programming paradigm:
It is divided into Logic, Functional, and Database programming paradigms. In computer
science the declarative programming is a style of building programs that expresses logic of
computation without talking about its control flow. Declarative programming is a
programming paradigm in which the programmer defines what needs to be accomplished
by the program without defining how it needs to be implemented. In other words, the
approach focuses on what needs to be achieved instead of instructing how to achieve it. It
just declares the result we want rather how it has be produced. This is the only difference
between imperative (how to do) and declarative (what to do) programming paradigms.
a. Logic programming paradigms: The logic programming paradigm takes a
declarative approach to problem-solving. It's based on formal logic. The logic
programming paradigm isn't made up of instructions. Rather it's made up of facts
and clauses. It uses everything it knows and tries to come up with the world where all
of those facts and clauses are true. It can be termed as abstract model of
computation. It would solve logical problems like puzzles, series etc. In logic
programming facts and clauses are given to the machine to produce results.
In logical programming the main emphasize is on knowledge base (facts and
clauses) and the problem. The execution of the program is very much like proof of
mathematical statement, e.g., Prolog
b. Functional programming paradigms: The functional programming paradigm has its
roots in mathematics and it is language independent. The key principal of this
paradigm is the execution of series of mathematical functions. The central model for
the abstraction is the function which is meant for some specific computation and
not the data structure. Data are loosely coupled to functions.. Function can be
replaced with their values without changing the meaning of the program. Some of
the languages like JavaScript, Haskell mostly uses this paradigm.
c. Database/Data driven programming approach: This programming methodology is
based on data and its movement. Program statements are defined by data rather
than hard-coding a series of steps. A database program is the heart of a business
information system and provides file creation, data entry, update, query and
reporting functions. There are several programming languages that are developed
mostly for database application. For example SQL.