Monday, February 29, 2016

Programming Paradigms(Approaches)

Dear Folks,
Let's discuss different programming paradigms used in software development and list programming languages falling under those paradigms.

The literal meaning of paradigm is 
paradigm
ˈparədʌɪm/
noun
  1. 1.
    a typical example or pattern of something; a pattern or model.
    "society's paradigm of the ‘ideal woman’"
  2. 2.
    LINGUISTICS
    a set of linguistic items that form mutually exclusive choices in particular syntactic roles.
    "English determiners form a paradigm: we can say ‘a book’ or ‘his book’ but not ‘a his book’"

It should pronounced keeping 'g' silent like paradime('para' -- as in parameter and 'dime' as in dimension).

Here in our programming context, it's meaning is programming model, approach, or methodology. Before we explore more about different programming paradigms, let's prepare a yummy pizza. Our first task is to find which type of pizza, then, depending on the type, we choose the method/approach/model of preparation .

 There are different methods or approaches available for preparing a yummy pizza. Look at the collage for mouth-watering pizzas,all have been prepared using different methods,but finally it's a Pizza...

Similarly, a program(software) can be developed using different approaches, each approach having it's own set of unique characteristics. Here it is called Programming Paradigm..
Currently the IT industry is using following four common programming paradigms... 

1. Imperative Paradigm
2. Functional Paradigm
3. Logic Paradigm
4. Object Oriented Paradigm

Let's discuss these in brief, and will have elaborate discussion on object oriented programming paradigm in our next post.

1. Imperative Paradigm: 

"First do this and next do that" is the slogan of this model.
We know imperative means,something very important, crucial or urgent, So here focus will be on order and discipline. It implements the traditional Von Neumann Concept.Control flow in imperative programming is explicit, and commands show how  the computation takes place, step by step. 
Fortran, Baisc, Pascal and C are the programming languages of this paradigm.

2. Functional Paradigm:

" Evaluate an Expression and use the result " is the slogan of this paradigm.
Functional programming languages define programs and subroutines as mathematical functions. Many so-called functional languages are "impure", containing imperative features. 
The salient features of this paradigm are...
  • There are no commands, only side-effect free expressions
  • Code is much shorter, less error-prone, and much easier to prove correct
  • There is more inherent parallelism, so good compilers can produce faster code
Note:In computer science, a function or expression is said to have a side effect if it modifies some state or has an observable interaction with calling functions or the outside world. For example, a particular function might modify a global variable or static variable, modify one of its arguments, raise an exception, write/read data to a file etc.
The examples of programming language implementing this model are, Java(Java version 8 onward),Python,Scala, R, Ruby and Haskel being the purest.

3. Logic Paradigm: 

Logic Paradigm is one in which programs are built by setting up relations that specify facts and inference rules, and asking whether or not something is true (i.e. specifying a goal.) 
Languages that emphasize this paradigm are Prolog, GHC, Parlog, Vulcan, Polka, Mercury, Fnil.


4. Object Oriented Paradigm: 

This the most widely and commonly used paradigm, that focuses on data(objects) rather than procedure or logic. Through this paradigm one can encapsulate data.
OOP is based on sending of messages to objects. Objects respond to messages by performing operations. Messages can have arguments, so "sending messages" is nothing but calling a function.
This approach makes the software development process simple, there by allowing easy development and up gradation of software. Data protection, Reuasbility of code and dynamism are the key advantages of this paradigm.
It is identified with following key features
i.   Data Abstraction
ii.  Data Encapsulation
iii. Classes and Objects
iv. Inheritance
v.  Polymorphism
A detailed discussion on this paradigm will be made in the next post.
Smalltalk,Ada, Eiffel, Objective C, C++ ,C# and Java are the examples of this paradigm.
Let me summarize these four paradigms with help this image


Please, Comment and give your feed back about this post. If you have any suggestions , we can incorporate in this post.
References:

1.http://cs.lmu.edu/~ray/notes/paradigms/
2.http://people.cs.aau.dk/~normark/prog3-03/html/notes/paradigms_themes-paradigm-overview-section.html

No comments:

Post a Comment