314450: programming paradigms

24
314450: PROGRAMMING PARADIGMS Teaching scheme: Examination Scheme: Lectures: 3 Hours/Week Theory: 100 Marks OBJECTIVE: •To understand the basic building blocks of programming Languages. •To Learn and understand various programming paradigms.

Upload: colette-cantrell

Post on 30-Dec-2015

60 views

Category:

Documents


0 download

DESCRIPTION

Teaching scheme: Examination Scheme: Lectures: 3 Hours/Week Theory: 100 Marks OBJECTIVE: To understand the basic building blocks of programming Languages. To Learn and understand various programming paradigms. 314450: PROGRAMMING PARADIGMS. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMS

Teaching scheme: Examination Scheme:Lectures: 3 Hours/Week Theory: 100 Marks

OBJECTIVE:

•To understand the basic building blocks of programming Languages.

•To Learn and understand various programming paradigms.

Page 2: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMS

UNIT - I• Introduction:• Role of programming languages, Need to study

programming languages, Characteristics of Programming Languages, Programming language

• paradigms: Imperative, Object Oriented, Functional, Logic, Event Driven and Concurrent Programming, Language design issues, Language

• translation issues, Data Types: properties of Types and objects, Elementary data types, structured data types, Type conversion, Binding and binding times.

Page 3: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMS

UNIT - I• Introduction:• Role of programming languages, Need to study

programming languages, Characteristics of Programming Languages, Programming language

• paradigms: Imperative, Object Oriented, Functional, Logic, Event Driven and Concurrent Programming, Language design issues, Language

• translation issues, Data Types: properties of Types and objects, Elementary data types, structured data types, Type conversion, Binding and binding times.

Page 4: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMSUNIT – II

• Procedures:

• Sequence Control: Implicit and explicit sequence control, sequencing with arithmetic expressions, sequencing with Nonarithmetic expressions,sequence control between statements.

• Subprogram control: subprogram sequence control, attributes of data control, shared data in subprograms, different parameter passing methods, lifetime of variables, Storage management, Exceptions and exception handling. Desirable and undesirable characteristics of procedural programming. Case study of Pascal.

Page 5: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMSUNIT - III

• Object Oriented Programming: • General characteristics for object based programming, Design

Principles for object oriented programming, Implementing object oriented programming, desirable characteristics of object oriented programming.

• Object Oriented Programming in Java :• Abstraction, Inheritance, Polymorphism, I/O, access specification,

interfaces, packages, exception handling, multithreading, event handling.

• AWT: working with windows, Graphics, Text, using AWT controls,layout manager and menus. Comparative study of C++ and JAVA.

Page 6: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMSUNIT – IV

• Declarative Programming Paradigm: • Logic programming language model, logical statements,

Resolution, Unification, Search structures, Applications of Logic programming. Case study of Prolog.

• Applicative programming Paradigm:• Lambda calculus: Ambiguity, free and bound identifiers,

reductions, typed lambda calculus, principles of functional programming. Case study of LISP

Page 7: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMSUNIT – V

• Parallel Programming Paradigm :

• Classification of computer architectures, principles of parallel programming, precedence graph, data parallelism, control parallelism, message passing, shared address space, synchronization mechanisms, mapping, granularity, compilers, operating systems.

Page 8: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMSUNIT – VI

• Additional Programming Paradigms: • Data flow programming design principles, Database

programming design principles, Network programming design principles, Socket programming in JAVA, Internet programming design principles, windows programming.

Page 9: 314450: PROGRAMMING PARADIGMS

314450: PROGRAMMING PARADIGMS• Text Books:• 1. Roosta Seyed, “Foundations of Programming Languages Design

& Implementation”, 3rd Edition, Cenage learning. ISBN-13:978-81-315-1062-9.

• 2. Pratt T.W., Zelkowitz “Programming Languages : Design and Implementation ”PHI, 2002, 3rd Edition.ISBN-81-203-1038-1

• Reference Books:• 1. Sebesta R. W., “Concepts of programming languages”, Pearson

Education 2001,4th edition.ISBN-81-317-0837-3.• 2. Sethi Ravi, “Programming Languages: Concepts and Constructs”

Pearson Education, ISBN: 9788177584226• 3. Herbert Schildt “ The Complete Reference Java2”, 5th edition,

Tata McGraw Hill, ISBN-13: 978-0-07-049543-2.

Page 10: 314450: PROGRAMMING PARADIGMS

INTRODUCTION

314450: PROGRAMMING PARADIGMS

Page 11: 314450: PROGRAMMING PARADIGMS

Goals / Objectives• To gain an understanding of the basic structure of

programming languages:– Data types, control structures, naming conventions,...

• To learn the principles underlying all programming languages:– So that it is easier to learn new languages

• To study different language paradigms:– Functional (Scheme), Imperative (C), Object-Oriented (C++,

Java), Logic (Prolog).– So that you can select an appropriate language for a task

Page 12: 314450: PROGRAMMING PARADIGMS

What is a ProgrammingLanguage?

• “A language intended for use by a person to express a process by which a computer can solve a problem” -Hope and Jipping

• “A set of conventions for communicating an algorithm” -E.Horowitz

• “ The art of programming is the art of organizing complexity” -Dijkstra, 1972

Page 13: 314450: PROGRAMMING PARADIGMS

Design Criteria for PL• Readable

– comments, names, (…) syntax

• Simple to learn– Feature multiplicity E.g.:-Count=count+1, count+=1,count++.– Orthogonal - small number of concepts combine regularly and systematically (without

exceptions).

• Portable– language standardization– Ease with which programs can be moved from one implementation to another

• Writability– How easily a language can be used to create programs for a chosen problem domain.

• Abstraction– control and data structures that hide detail

• Efficient

Page 14: 314450: PROGRAMMING PARADIGMS

Why learn more than one PL?

• So you can choose the right language for a given problem– If all you have is a hammer, every problem looks like a

nail.• So you can learn a new language more easily later

– As your job changes, you may need to used different languages

– As our understanding of programming improves, new languages are created

• To learn new ways of thinking about problems– Different languages encourage you to think about

problems in different ways– “Paradigms”

Page 15: 314450: PROGRAMMING PARADIGMS

What is a Paradigm?• A way of looking at a problem and seeing a

program– What kind of parts do you look for?

• Problem: Print a “large X” of size n.• E.g., size 5 is

X X X X X X X X X

Page 16: 314450: PROGRAMMING PARADIGMS

Paradigms of Programming?

• There are several ways to think about computation:– a set of instructions to be executed– a set of expressions to be evaluated– a set of rules to be applied– a set of objects to be arranged– a set of messages to be sent and received

Page 17: 314450: PROGRAMMING PARADIGMS

Some Programming Paradigms

• Procedural– examples: C, Pascal, Basic, Fortran

• Functional– examples: Lisp, ML

• Object-oriented– examples: C++, Java, Smalltalk

• Rule-based (or Logic)– example: Prolog

Page 18: 314450: PROGRAMMING PARADIGMS

Why so many?

• Most important: the choice of paradigm (and therefore language) depends on how humans best think about the problem

• Other considerations:– efficiency– compatibility with existing code– availability of translators

Page 19: 314450: PROGRAMMING PARADIGMS
Page 20: 314450: PROGRAMMING PARADIGMS

Models of Computation

• RAM machine– procedural

• directed acyclic graphs– Smalltalk model of O-O

• partial recursive functions– Lisp and ML

• Markov algorithms– Prolog is loosely based on these

Page 21: 314450: PROGRAMMING PARADIGMS

Lots of Languages

• There are many programming languages out there• Lots of other PL-like objects

– document languages, e.g. LaTeX, Postscript– command languages, e.g. bash, MATLAB– markup languages, e.g. HTML and XML– specification languages, e.g. UML

Page 22: 314450: PROGRAMMING PARADIGMS

Issues for all Languages

• Can it be understood by people and processed by machines?– although translation may be required

• Sufficient expressive power?– can we say what needs to be said, at an

appropriate level of abstraction?

Page 23: 314450: PROGRAMMING PARADIGMS

Translation

• Compilation– Translate into instructions suitable for some other

(lower level) machine– During execution, that machine maintains

program state information

• Interpretation– May involve some translation– Interpreter maintains program state

Page 24: 314450: PROGRAMMING PARADIGMS

Trade-offs

• Compilation– lower level machine may be faster, so

programs run faster– compilation can be expensive– examples: C (and Java?)

• Interpretation– more ability to perform diagnostics (or

changes) at run-time– examples: Basic, UNIX shells, Lisp