Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture on Programming Languages

Similar presentations


Presentation on theme: "Lecture on Programming Languages"— Presentation transcript:

1 Lecture on Programming Languages
Chapter#5

2 Programming Paradigms/Models
Paradigm defines a model or way of programming We will discuss the following three paradigms Imperative/Procedural Paradigm Declarative Paradigm Object Oriented Paradigm

3 The evolution of programming paradigms

4 The composition of a typical imperative program or program unit

5 Procedural Units Local versus Global Variables
Formal versus Actual Parameters Passing parameters by value versus reference Procedures versus Functions

6 The flow of control involving a procedure

7 Example of procedure written in C language

8 Executing the procedure Demo and passing parameters by value

9 Executing the procedure Demo and passing parameters by reference

10 Object Oriented Paradigm
In this approach all real world things are considered as an object. Each object has a certain set of qualities/ attributes and each object can perform some job/method. Thus if I have an object CAR then Car has its color, engine#, make, model etc as attributes and its methods can be drive(), stop() etc Examples include C++, Java etc

11 Declarative Programming Approach
It emphasizes the question “What is the problem?” rather than “What algorithm is required for solving the problem?” Here a general problem solving approach is developed that can solve a number of problems. These languages are difficult to design and are special purpose by nature PROLOG (Programming LOGic) is an example

12 Figure 6.25 Resolving the statements (P OR Q), (R OR ¬Q), ¬R, and ¬P

13 Declarative Programming
Resolution: Combining two or more statements to produce a new statement (that is a logical consequence of the originals). Example: (P OR Q) AND (R OR Q) resolves to (P OR R) Resolvent: A new statement deduced by resolution Clause form: A statement whose elementary components are connected by the Boolean operation OR Unification: Assigning a value to a variable so that two statements become “compatible.”

14 Prolog Fact: A Prolog statement establishing a fact
Consists of a single predicate Form: predicateName(arguments). Example: parent(bill, mary). Rule: A Prolog statement establishing a general rule Form: conclusion :- premise. :- means “if” Example: wise(X) :- old(X). Example: faster(X,Z) :- faster(X,Y), faster(Y,Z).


Download ppt "Lecture on Programming Languages"

Similar presentations


Ads by Google