27
PROGRAMMING PARADIGM BY, Anirudh Chauhan

Prgramming paradigms

Embed Size (px)

Citation preview

Page 1: Prgramming paradigms

PROGRAMMING PARADIGM

BY,Anirudh Chauhan

Page 2: Prgramming paradigms

Introduction to programming paradigm

Page 3: Prgramming paradigms

Introduction

A way of conceptualizing what it means to perform computation and how tasks to be carried out on the computer should be structured and organized.

A programming paradigm is a fundamental style of computer programming, serving as a way of building the structure and elements of computer programs

Page 4: Prgramming paradigms

Introduction

Some languages are designed to support one particular paradigm Smalltalk supports object-oriented programming Haskell supports functional programming

Other programming languages support multiple paradigms Object Pascal, C++, C#, Visual Basic, Common

Lisp, Scheme, Perl, Python, Ruby, Oz and F#.

Page 5: Prgramming paradigms

Introduction

Programming paradigms differ in: The concepts and abstractions used to represent the elements of a program (such as objects, functions, variables, constraints, etc.)

The steps that compose a computation (assignation, evaluation, data flow, control flow, etc.).

Page 6: Prgramming paradigms

Programming Paradigms

Page 7: Prgramming paradigms

Programming paradigms

There are four main Programming Paradigms.

Imperative : Machine-model based Functional : Equations; Expression

Evaluation

Logical : First-order Logic Deduction

Object-Oriented : Programming with Data

Types

Page 8: Prgramming paradigms

Why study so many programming languages ?

To Improve our ability to Develop Effective algorithms.

To improve Use of Existing Programming Languages. To allow a better choice of Programming Language. To make it Easier to design a new language.

Page 9: Prgramming paradigms

Procedural Programming

Page 10: Prgramming paradigms

Procedural Programming

Often thought as a synonym for imperative programming.

Specifying the steps the program must take to reach the desired state.

Based upon the concept of the procedure call.

Page 11: Prgramming paradigms

Procedural Programming

Procedures, also known as routines, subroutines, methods, or functions that contain a series of computational steps to be carried out.

Any given procedure might be called at any point during a program's execution, including by other procedures or itself.

The syntax of such languages generally has the form

statement 1;statement 2;--------------statement n;

Page 12: Prgramming paradigms

Procedural Programming

Often a better choice than simple sequential or unstructured programming in many situations which involve moderate complexity or require significant ease of maintainability.

The ability to re-use the same code at different places in the program without copying it.

Page 13: Prgramming paradigms

Procedural Programming

An easier way to keep track of program flow than a collection of "GOTO" or "JUMP" statements .

The ability to be strongly modular or structured. Example of procedural programming are C, Pascal, Basic,

FORTRAN etc.

Page 14: Prgramming paradigms

Functional Programming

Page 15: Prgramming paradigms

Functional Programming

Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state changes and mutable data.

Programs written using the functional programming paradigm are much more easily representable using mathematical concepts, and thus it is much more easy to mathematically reason about functional programs than it is to reason about programs written in any other paradigm.

Page 16: Prgramming paradigms

Functional Programming

The syntax of such languages is :functionn { …function2 { function1 (data)} …}

LISP was the first operational functional programming language.

The Haskell programming language was released in the late 1980s in an attempt to gather together many ideas in functional programming research.

Up to this day, functional programming has not been very popular except for a restricted number of application areas, such as artificial intelligence.

Page 17: Prgramming paradigms

Functional Programming

In practice, the difference between a mathematical function and the notion of a "function" used in imperative programming is that imperative functions can have side effects, changing the value of already calculated variables.

Conversely, in functional code, the output value of a function depends only on the arguments that are input to the function, so calling a function f twice with the same value for an argument x will produce the same result f(x) both times.

Examples of Functional Programming are C, LISP, ML .

Page 18: Prgramming paradigms

Imperative Vs Non Imperative

Page 19: Prgramming paradigms

Imperative VS non imperative

Functional/Logic programs specify WHAT is to be computed abstractly, leaving the details of data organization and instruction sequencing to the interpreter.

In contrast, Imperative programs describe the details of HOW the results are to be obtained, in

terms of the underlying machine model. Functional/Logic style clearly separates WHAT aspects of

a program (programmers’ responsibility) from the HOW aspects (implementation decisions).

An Imperative program contains both the specification and the implementation details, inseparably inter-twined.

Page 20: Prgramming paradigms

Imperative VS Non Imperative

Imperative•Program: a sequence of instructions for a von Neumann m/c.•Computation by instruction execution.•Iteration.•Modifiable or updateable variables.

Non imperative

•Program: a collection of function definitions (m/c independent).•Computation by term rewriting.•Recursion.•Assign-only-once variables.

Page 21: Prgramming paradigms

Logical Programming

Page 22: Prgramming paradigms

Logical Programming

Also known as Rule based programming and Declarative programming.

Rule based programming checks for presence for a certain condition and when present execute an appropriate action.

Page 23: Prgramming paradigms

Logical Programming

We can describe rule-based languages as a set of filters to apply to data storage. Enabling conditions determine order of execution. The syntax of such Languages generally is similar to the following.

enabling condition1→action1

enabling condition2→action2

.......................... enabling conditionn→actionn

Some examples of logical programming languages are Prolog, Ant, Oz, SQL etc.

Page 24: Prgramming paradigms

Object Oriented Programming

Page 25: Prgramming paradigms

Object Oriented Programming

Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures encapsulating data fields and procedures together with their interactions – to design applications and computer programs.

Associated programming techniques may include features such as data abstraction, encapsulation, modularity, polymorphism, and inheritance.

Page 26: Prgramming paradigms

Object oriented programming

Though it was invented with the creation of the Simula language in 1965, and further developed in Smalltalk in the 1970s, it was not commonly used in mainstream software application development until the early 1990s.

Many modern programming languages now support OOP.

Examples of Object oriented Programming are C++, java, Smalltalk, simula etc.

Page 27: Prgramming paradigms

Thank You for your consideration