1 / 14

Lecture on Programming Languages

Lecture on Programming Languages. Chapter#5. 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. The evolution of programming paradigms.

viho
Download Presentation

Lecture on Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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).

More Related