314450: programming paradigms
Download
Report
Transcript 314450: programming paradigms
314450: PROGRAMMING PARADIGMS
Teaching scheme:
Lectures: 3 Hours/Week
Examination Scheme:
Theory: 100 Marks
OBJECTIVE:
•To understand the basic building blocks of programming
Languages.
•To Learn and understand various 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.
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.
314450: PROGRAMMING PARADIGMS
UNIT – 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.
314450: PROGRAMMING PARADIGMS
•
•
•
•
•
UNIT - 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.
314450: PROGRAMMING PARADIGMS
UNIT – 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
314450: PROGRAMMING PARADIGMS
UNIT – 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.
314450: PROGRAMMING PARADIGMS
UNIT – 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.
314450: PROGRAMMING PARADIGMS
• Text Books:
• 1. Roosta Seyed, “Foundations of Programming Languages
Design & Implementation”, 3rd Edition, Cenage learning. ISBN13: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.
314450:
PROGRAMMING PARADIGMS
INTRODUCTION
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
What is a Programming
Language?
• “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
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
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”
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
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
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
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
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
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
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?
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
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