Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:

Slides:



Advertisements
Similar presentations
MT311 (Oct 2007) Java Application Development Object-Oriented Programming Languages Tutorial 8.
Advertisements

1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
COP4020 Programming Languages Names, Scopes, and Bindings Prof. Xin Yuan.
Programming Languages and Paradigms
Programming Languages and Paradigms The C Programming Language.
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Chapter 9 Subprograms Sections 1-5 and 9. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Introduction Two fundamental abstraction facilities.
Programming Languages Language Design Issues Why study programming languages Language development Software architectures Design goals Attributes of a good.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Introduction to Object-Oriented Programming (OOP)
Programming Languages Structure
Basic Definitions Data Structures: Data Structures: A data structure is a systematic way of organizing and accessing data. Or, It’s the logical relationship.
Abstract data types & object-oriented paradigm. Abstraction Abstraction: a view of an entity that includes only the attributes of significance in a particular.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
Lecture 9 Concepts of Programming Languages
C++ fundamentals.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
PZ01A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ01A -- Introduction Programming Language Design and.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
An Object-Oriented Approach to Programming Logic and Design
School of Computer Science & Information Technology G6DICP - Lecture 22 The Theory of Object Oriented Programming.
By Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion (Algol,
1 Programming Language History and Evolution In Text: Chapter 2.
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Programming Languages and Paradigms Object-Oriented Programming.
Object Oriented Programming Elhanan Borenstein copyrights © Elhanan Borenstein.
1 Scope Rules (Section 3.3) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos and Michael Scott.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
1 Scope Scope describes the region where an identifier is known, and semantic rules for this.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
Programming Languages and Paradigms Programming C++ Classes.
CSC3315 (Spring 2008)1 CSC 3315 Subprograms Hamid Harroud School of Science and Engineering, Akhawayn University
Programming Languages and Paradigms Imperative Programming.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Chapter 10, Slide 1 ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:  process abstraction  data abstraction Both provide:  information.
Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management.
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
Principles of programming languages 10: Object oriented languages Isao Sasano Department of Information Science and Engineering.
Inheritance and Subclasses CS 21a. 6/28/2004 Copyright 2004, by the authors of these slides, and Ateneo de Manila University. All rights reserved L16:
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Java Interfaces CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University (see Chapter 9 of.
Abstract data types Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Programming Language History and Evolution
Programming Languages and Paradigms
ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:
11.1 The Concept of Abstraction
Programming Paradigms
Types of Programming Languages
Programming Language History and Evolution
Evolution of programming languages
Lecture 9 Concepts of Programming Languages
Abstract Data Types and Encapsulation Concepts
Names, Binding, and Scope
Abstract Data Types and Encapsulation Concepts
Subprograms and Programmer Defined Data Type
Programming paradigms
Parameter Passing Actual vs formal parameters
Abstract data types Programming Language Design and Implementation
Principles of Programming Languages
Overview of Programming Paradigms
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
Programming Languages and Paradigms
Abstract data types Programming Language Design and Implementation
Programming Languages and Paradigms
Lecture 8 Object Oriented Programming (OOP)
11.1 The Concept of Abstraction
Lecture 9 Concepts of Programming Languages
Presentation transcript:

Programming Paradigms Introduction

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 2 Definitions Programming Language notation for specifying programs/computations consists of words, symbols, and rules for writing a program Programming Paradigm programming “technique” way of thinking about programming view of a program

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 3 Programming Paradigms Imperative Programming program as a collection of statements and procedures affecting data (variables) Object-Oriented Programming program as a collection of classes for interacting objects Functional Programming program as a collection of (math) functions Others

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 4 Some Languages by Paradigm Imperative (also called Structured or Procedural) Programming FORTRAN, BASIC, COBOL, Pascal, C Object-Oriented Programming SmallTalk, C++, Java Functional Programming LISP, ML, Haskell

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 5 History of Languages 1950s to 1960s FORTRAN, COBOL, LISP, BASIC 1960s to 1970s (ALGOL-based) Pascal and others 1970s to 1980s Prolog, C, Ada 1980s to 1990s C++, ML, Perl, Java

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 6 Paradigm Change For example, from Procedural to Object- Oriented Programming Arises from problems encountered in one paradigm but addressed in another Case study: from C to C++ Evolution from procedural, to modular, to object- based, to object-oriented programming Stroustrup book section 1.2 (2 nd edition, pp ): required reading material

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 7 Case Study: Stacks Stack last-in, first-out structure operations: push, pop Stacks are used to support some solution push and pop are defined and implemented as functions the solution consists of code that invoke these functions

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 8 Implementing a Stack Stack can be implemented as an array array contains pushed elements an integer refers to top of the stack most common implementation Or as a linked list using pointers and dynamic allocation Other implementations

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 9 Array Implementation in C char Store[MAX]; int top = 0; void push(char x) { if (top < MAX) Store[top++] = x; else printf(“full\n”); } char pop() { if (top > 0) return Store[--top]; else printf(“empty\n”); }...

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 10 Using the Stack void application() { … push(‘x’); … result = pop(); … }

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 11 Procedural Programming Focus is on writing good functions and procedures use the most appropriate implementation and employ correct efficient algorithms Stack example (assume array implementation) one source file Store and top are global variables stack and application functions defined at the same level (file)

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 12 Problems Application can alter implementation details can directly manipulate top and Store from application() integrity of stack not ensured Stack code and application code are not separated

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 13 Encapsulation and Modular Programming Focus is on writing good modules hide implementation details from user provide an interface Stack example stack.h contains prototypes for push, pop stack.c contains stack code, Store and top declared static (local to stack.c) application includes stack.h

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 14 Benefits from Modules Application cannot destroy the integrity of the stack Stack implementation can change without affecting application source Question: what happens if we need more than one stack?

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 15 Multiple Stacks Strategy 1 (use structs) in stack.h, define a stack structure that contains Store and top; push, pop now have an extra parameter that specifies which stack application code defines stack variables Strategy 2 (use handles) implement multiple data structures in stack.c use an integer (the handle) to specify “stack number”

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 16 Modules and Multiple Stacks Disadvantage of strategy 1: implementation (data) is exposed back to original problem on stack integrity Disadvantage of strategy 2: stack module will be unnecessarily complex handle is artificial (what if an arbitrary integer is passed?)

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 17 Abstract Data Types and Object-based Programming Focus is on writing good classes (or types) that define operations on objects of the class class defined like a module (encapsulation enforced) but multiple instances now possible user-defined type Stack example (C++) stack.h and stack.cpp define a stack class

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 18 Object-Oriented Programming Incorporates both encapsulation and inheritance through the class concept Focus is on writing good classes and on code reuse Examples Shape, Circle, and Rectangle in a drawing program Employee, Faculty, Staff in a university personnel system

6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1: Introduction Slide 19 What’s Next? Survey of languages by paradigm Discussion of language features and language design decisions Related areas: language implementation, translation, syntax, semantics