Jigar Gaglani.  Programming paradigm is a fundamental style of computer programming  Paradigms differ in concepts and abstractions used to represent.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

An Introduction to Programming General Concepts. What is a program? A program is an algorithm expressed in a programming language. programming language.
Structures. Procedural (Imperative) Languages Procedural languages work on the basis of explicitly telling the computer ‘how to do something’; by using.
Intermediate Code Generation
Programming Paradigms and languages
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Classes & Objects Computer Science I Last updated 9/30/10.
Jigar Gaglani.  A Programming language is a notational system for describing computations in a machine and human readable form.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 10 Exercises –Solutions to Exercises of LPN chapter 9 Theory –Explain how to control Prolog`s.
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
Overview of Programming Paradigms
High-Level Programming Languages
Programming Languages Structure
Chapter 1 Principles of Programming and Software Engineering.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Programming Languages – Coding schemes used to write both systems and application software A programming language is an abstraction mechanism. It enables.
Object Oriented Software Development
OOP- OBJECT OBJECT PROGRAMMING By KRATI SHARMA 02 XI-B ✏✏✏✏ ☺☻☺☻☺☻☺ ✏✏✏✏
Programming Languages
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014 Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
An Object-Oriented Approach to Programming Logic and Design
1 Programming Language History and Evolution In Text: Chapter 2.
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
Chapter 6 Programming Languages © 2007 Pearson Addison-Wesley. All rights reserved.
CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Learners Support Publications Object Oriented Programming.
9-Dec Dec-15  INTRODUCTION.  FEATURES OF OOP.  ORGANIZATION OF DATA & FUNCTION IN OOP.  OOP’S DESIGN.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Programming and Languages Dept. of Computer and Information Science IUPUI.
Introduction to OOP CPS235: Introduction.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Software Design and Development Languages and Environments Computing Science.
Welcome to OBJECT ORIENTED PROGRAMMING Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Language Paradigms CS655.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Programming Paradigms, Software Architectural Patterns, and MVC CS 378 – Mobile Computing for iOS Dr. William C. Bulko.
Programming Language History and Evolution
Programming Languages 2nd edition Tucker and Noonan
OOP - Object Oriented Programming
Programming paradigms
Visit for more Learning Resources
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Why study programming languages?
CHAPTER 5 GENERAL OOP CONCEPTS.
An Introduction to Programming
Types of Programming Languages
Programming Language History and Evolution
Computer Programming.
Prolog: cut & fail © Patrick Blackburn, Johan Bos & Kristina Striegnitz.
Programming Languages 2nd edition Tucker and Noonan
An Introduction to Programming
Presentation transcript:

Jigar Gaglani

 Programming paradigm is a fundamental style of computer programming  Paradigms differ in concepts and abstractions used to represent the elements of program

 Procedural/Imperative  Functional  Logic  Object-Oriented

 Derived from latin word imperare means “to command”  It is based on commands that update variables in storage  Is a programming paradigm that describes computation in terms of statements that change a program state.

 It defines sequences of commands for the computer to perform  Imperative programming is characterized by programming with a state and commands

 In imperative programming, a name may be assigned to a value and later reassigned to another value.  A name is tied to two bindings, a binding to a location and to a value.  The location is called the l-value and the value is called the r-value.

 For example, X := X+2  Assignment changes the value at a location.  A program execution generates a sequence of states

 The unstructured commands contains: assignment command, sequential composition of commands, a provision to identify a command with a label, unconditional and conditional GOTO commands

 The unconditional goto command has the form: goto LABEL i  The sequence of instructions next executed begin with the command labeled with LABEL i.  The conditional goto command has the form: if conditional expression then goto LABEL i

 The goal of structured programming is to provide control structures that make it easier to reason about imperative programs.

 an IF statement corresponds to an If condition then command and a DO statement corresponds to a While condition Do command. IF guard --> command FI=if guard then command DO guard --> command OD=while guard do command

 An imperative program can only be understood in terms of its execution behavior.  Thus, the whole program may need to be examined in order to understand even a small portion of code.

 The program is built from one or more procedures  It provides a programmer a means to define precisely each step in the performance of a task.

 The ability to re-use the same code at different places in the program without copying it.  An easier way to keep track of program flow than a collection of "GOTO" or "JUMP" statements

 Declarative programming is a non- imperative style of programming  Does not explicitly list command or steps that need to be carried out to achieve the results.

 For example: List collection = new List {1,2,3,4,5 };  Imperative programming List results = new List (); foreach(var num in collection) { if (num % 2 != 0) results.Add(num); }

 Declarative programming var results = collection.Where( num=>num%2 != 0);  Does not step through the collection

 Procedural Assembler, Fortran, Cobol, C, etc  Non-Procedural SQL, Visual Basic, etc etc.

 It treats computation as the evaluation of mathematical functions and avoids state and mutable data.  It emphasizes the application of functions, in contrast to the imperative programming style

 Functional programming is all about expressions.  Functions are used as objects in FP.  Functional Programming is about abstraction and reducing complexity

 spam = ['pork','ham','spices'] numbers = [1,2,3,4,5] def eggs(item): return item map(aFunction, aSequence)

 L = map(eggs, spam) print L  Same thing could have been done by: for i in spam: L.append(i) print L

 If we want to create a new list of only odd numbers : def isOdd(n): return (n%2 != 0) L = filter(isOdd, numbers) print L  Alternatively def isOdd(n): return (n%2 != 0) for i in numbers: if isOdd(i): L.append(i) print L

 It is the use of mathematical logic for computer programming  The problem-solving task is split between the programmer and theorem-prover

 To study logic programming means to study proofs.  It is based upon the fact of a backwards reasoning proof  Eg. : If B 1 and … and B n then H

 Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics  It is based on Facts and Rules

 Simple Facts: Facts either consist of a particular item or a relation between items.  For Eg : the fact that it is sunny is represented by writing the program : sunny.  We can now ask a query of Prolog by asking ?- sunny.

 facts consist of a relation and the items that this refers to, called arguments  A general model is shown below: relation(,,...., ).

 The basic Prolog terms are an integer, an atom, a variable or a structure.  Example : likes(john,mary).  In the above fact john and mary are two atomes.

 Consider the following sentence : 'All men are mortal'  We can express this as : mortal(X) :- human(X).  Let us define the fact that Socrate is a human. mortal(X) :- human(X). human(socrate).

 Now if we ask to prolog : ?- mortal(socrate).  What prolog will respond ?  Why ?

 One of Prolog's most useful features is the simple way it lets us state generalizations.  Example: enjoys(vincent,X) :- burger(X).  Vincent enjoys burgers, except Big Kahuna burgers, how do we state this in Prolog?

 As a first step, let's introduce another built in predicate fail/0  fail enables us to write some interesting programs, and in particular, it lets us define exceptions to general rules

 Consider the following code: enjoys(vincent,X) :- big_kahuna_burger(X),!,fail. enjoys(vincent,X) :- burger(X). burger(X) :- big_mac(X). burger(X) :- big_kahuna_burger(X). big_mac(a). big_kahuna_burger(b). big_mac(c).

 The first two lines describe Vincent's preferences.  The last 4 lines describe a world containing 3 burgers, a, b, and c

 This is what happens: ?- enjoys(vincent,a). yes ?- enjoys(vincent,b). no ?- enjoys(vincent,c). yes

 The key is the combination of ! and fail in the first line  This cut-fail combination lets us define a form of negation called negation as failure  General notation: neg(Goal) :- Goal,!,fail. neg(Goal).

 For any Prolog goal, neg(Goal) will succeed precisely if Goal does not succeed.  Using our new neg predicate, we can describe Vincent's preferences as: enjoys(vincent,X) :- burger(X), neg(big_kahuna_burger(X)).

 Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures consisting of datafields and methods together with their interactions – to design applications and computer programs.

 It is a paradigm where we focus real life objects while programming any solution.  We actually write behaviours of our programming objects, those behaviours are called methods in objected oriented programming.

 They enable programmers to create modules that do not need to be changed when a new type of object is added.  A programmer can simply create a new object that inherits many of its features from existing objects.

 Class  Object  Instance  Method  Message passing  Inheritance  Abstraction  Encapsulation  Polymorphism  Decoupling

 Encapsulation: a logical boundary around methods and properties  Inheritance  Re-usability method overloading and overriding  Information Hiding is achieved through "Access Modifiers"

 What are the differences between these programming paradigms, and are they better suited to particular problems or do any use-cases favor one over the others?

 ming  Files/plbook/imperati.htm  ming  tutorial.org/functional_programming   now/html/node90.html