David Evans CS200: Computer Science University of Virginia Computer Science Lecture 22: Objects I invented the term Object-

Slides:



Advertisements
Similar presentations
Programming Paradigms and languages
Advertisements

David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 23: Inheritance.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. slide 1 CS 125 Introduction to Computers and Object- Oriented Programming.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. slide 1 CS 125 Introduction to Computers and Object- Oriented Programming.
Principles of Object-oriented Programming Programming Language Paradigms August 26, 2002.
CS 106 Introduction to Computer Science I 03 / 03 / 2008 Instructor: Michael Eckmann.
Yixin Sun Class 17: Concurrency and OOP Fall 2010 UVa David Evans cs2220: Engineering Software.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 28: Implementing Interpreters.
Cs1120 Fall 2009 David Evans Lecture 19: Stateful Evaluation.
1 CSC 221: Computer Programming I Fall 2004 course overview  what did we set out to learn?  what did you actually learn?  where do you go from here?
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 12: Subtyping and Inheritance.
3A-1 1 Introduction to Smalltalk History of Smalltalk The philosophy of Smalltalk:  “...we have a universe of well-behaved objects that courteously ask.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
SE-1010 Dr. Mark L. Hornick 1 Introduction to Object-Oriented Programming (OOP) Part 1.
Class 30: Language Construction cs1120 Fall 2009 David Evans.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 27: Viruses and Object-Oriented Programming.
CS 152: Programming Language Paradigms March 10 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 22: Objectifying Objects.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 18: Think Globally, Mutate Locally.
David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Fixed Points and Biological Computing.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
David Evans CS200: Computer Science University of Virginia Computer Science Class 17: Mutation M. C. Escher, Day and Night.
1 The Evaluator. 2 Compiler vs. Interpreter Command Processing Unit The Computer Program in Low Level Machine Language Program in High Level Language.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 20: Objects I invented the term Object-
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 26: Proving Uncomputability.
Alan Kay: LCC 2700: Intro to Computational Media Spring 2005.
Salman Marvasti Sharif University of Technology Winter 2015.
Chapter 12 Support for Object-Oriented Programming.
David Evans CS200: Computer Science University of Virginia Computer Science Class 16: Mutation M. C. Escher, Day and Night.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 19: Environments.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 23: Programming with Objects.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 18: Mutation M. C. Escher, Day and.
OO in Context Lecture 13: Dolores Zage. Confused about OO Not alone, there is much confusion about OO many programs are claimed to be OO but are not really.
Introduction To OOP 1.0 Fundamentals Of Java Programming Language 2.0 Exception Handling 3.0 Classes, Inheritance And Polymorphism © 2011 | PN AZRINA.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Lecture 3: Rules of Evaluation CS150: Computer Science
Procedure Definitions and Semantics Procedures support control abstraction in programming languages. In most programming languages, a procedure is defined.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 22: Objectifying Objects.
Cs205: engineering software university of virginia fall 2006 David Evans Object-Oriented Programming.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 21: Inheritance.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 12: Behavioral Subtyping.
Augmenting Understanding: 2 Digital Innovators LCC 2700: Intro to Computational Media Fall 2005 Ian Bogost.
(Thunking about Thunks)
CS 325 Spring ‘09 Chapter 1 Goals:
Praktische Informatik 1
Lecture 4: Metacircles Eval Apply David Evans
David Evans Class 20: Objects I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. — Alan.
Lecture 1: Introduction Background just got here last week
LCC 2700: Intro to Computational Media
Lecture 6: Lambda Calculus
Lecture 4: Evaluation Rules Recursion CS200: Computer Science
Class 22: Inheritance CS150: Computer Science University of Virginia
Class 19: Think Globally, Mutate Locally CS150: Computer Science
Class 23: Gödel’s Theorem CS150: Computer Science
Introduction to Database Systems
Lecture 21: Inheritance CS200: Computer Science University of Virginia
Lecture 28: Types of Types
Lecture 25: Metalinguistics > (meval '((lambda (x) (* x x)) 4)
Lecture 24: Metalinguistics CS200: Computer Science
Lecture 27: In Praise of Idleness CS200: Computer Science
Lecture 26: The Metacircular Evaluator Eval Apply
Lecture 12: Message passing The Environment Model
Lecture 13 - Assignment and the environments model Chapter 3
Lecture 3: Rules of Evaluation CS200: Computer Science
Let’s Talk about… Smalltalk.
Lecture 25: The Metacircular Evaluator Eval Apply
Presentation transcript:

David Evans CS200: Computer Science University of Virginia Computer Science Lecture 22: Objects I invented the term Object- Oriented, and I can tell you I did not have C++ in mind. — Alan Kay

15 March 2004CS 200 Spring Menu A better counter PS5 Comments –Databases Programming with Objects

15 March 2004CS 200 Spring nextx from Lecture 17 (define x 0) (define (nextx) (set! x (+ x 1)) x) > (nextx) 1 > (set! x 23) > (next x) 24 global environment + : # nextx: x : 24 parameters: body: (begin (set! x (+ x 1)) x)

15 March 2004CS 200 Spring A Better Counter The place that keeps track of the count would be part of the counter, not part of the global environment Can we do this?

15 March 2004CS 200 Spring Application 1.Construct a new frame, enclosed in the environment of this procedure 2.Make places in that frame with the names of each parameter 3.Put the values of the parameters in those places 4.Evaluate the body in the new environment Recall from Lecture 17:

15 March 2004CS 200 Spring A Better Counter (define (make-counter) ((lambda (count) (lambda () (set! count (+ 1 count)) count)) 0))

15 March 2004CS 200 Spring > (define mycount (make-counter)) > (mycount) global environment + : # make-counter: parameters: body: ((lambda … count : 0 (define (make-counter) ((lambda (count) (lambda () (set! count (+ 1 count)) count)) 0)) mycount: parameters: body: (lambda () (set! count …) 1 2 3

15 March 2004CS 200 Spring An Even Better Counter (define (make-ocounter) ((lambda (count) (lambda (message) (if (eq? message 'reset) (set! count 0) (if (eq? message 'next) (set! count (+ 1 count)) (if (eq? message 'how-many) count))))) 0))

15 March 2004CS 200 Spring Using Counter > (define bcounter (make-ocounter)) > (bcounter 'next) > (bcounter 'how-many) 3 > (bcounter 'reset) > (bcounter 'how-many) 0

15 March 2004CS 200 Spring Objects When we package state and procedures together we have an object Programming with objects is object-oriented programming

15 March 2004CS 200 Spring PS5 How are commercial databases different from what you implemented for PS5? UVa’s Integrated Systems Project to convert all University information systems to use an Oracle database was originally budgeted for $58.2 Million (starting in 1999). Actual cost is likely to be $100 Million.

15 March 2004CS 200 Spring Real Databases Atomic Transactions: a transaction may involve many modifications to database tables, but the changes should only happen if the whole transaction happens (e.g., don’t charge the credit card unless the order is sent to the shipping dept) Security: limit read/write access to tables, entries and fields Storage: need to efficiently store data on disk, provide backup mechanisms Scale: to support really big data tables, real databases do lots of clever things

15 March 2004CS 200 Spring How big are big databases? Microsoft TerraServer –Claimed biggest in 1998 –Aerial photos of entire US (1 meter resolution)

15 March 2004CS 200 Spring You are here Rotunda Amphitheater

15 March 2004CS 200 Spring AFC? Picture from 2 Apr 1994 You are here

15 March 2004CS 200 Spring Big Databases Microsoft TerraServer –3.3 Terabytes (claimed biggest in 1998) –1 Terabyte = 2 40 Bytes ~ 1 Trillion Bytes Wal-Mart –285 Terabytes (2003) Stanford Linear Accelerator (BaBar) –500 Terabytes (30 KB per particle collision)

15 March 2004CS 200 Spring How much work? table-select is  ( n ) where n is the number of entries in the table –Would your table-select work for Wal-Mart? –If 1M entry table takes 1s, how long would it take Wal-Mart to select from 285TB ~ 2 Trillion Entries? s ~ 23 days How do expensive databases perform so much faster?

15 March 2004CS 200 Spring Object-Oriented Programming

15 March 2004CS 200 Spring Simula Considered the first “object-oriented” programming language Language designed for simulation by Kristen Nygaard and Ole-Johan Dahl (Norway, 1962) Had special syntax for defining classes that packages state and procedures together

15 March 2004CS 200 Spring Counter in Simula class counter; integer count; begin procedure reset(); count := 0; end; procedure next(); count := count + 1; end; integer procedure how-many(); how-many := count; end; end

15 March 2004CS 200 Spring XEROX Palo Alto Research Center (PARC) 1970s: Bitmapped display Graphical User Interface –Steve Jobs paid $1M to visit and PARC, and returned to make Apple Lisa/Mac) Ethernet First personal computer (Alto) PostScript Printers Object-Oriented Programming

15 March 2004CS 200 Spring Dynabook, 1972 The best way to predict the future is to invent it. Alan Kay (Just a model)

15 March 2004CS 200 Spring Dynabook 1972 Tablet computer Intended as tool for learning Kay wanted children to be able to program it also Hallway argument, Kay claims you could define “the most powerful language in the world in a page of code” Proof: Smalltalk –Scheme is as powerful, but takes two pages

15 March 2004CS 200 Spring BYTE Magazine, August 1981

15 March 2004CS 200 Spring Smalltalk Everything is an object Objects communicate by sending and receiving messages Objects have their own state (which may contain other objects) How do you do 3 + 4? send the object 3 the message “+ 4”

15 March 2004CS 200 Spring Counter in Smalltalk class name counter instance variable names count new count <- 0 next count <- count + 1 how-many ^ count

15 March 2004CS 200 Spring Counter in Scheme (define (make-ocounter) ((lambda (count) (lambda (message) (if (eq? message 'reset) (set! count 0) (if (eq? message 'next) (set! count (+ 1 count)) (if (eq? message 'how-many) count))))) 0))

15 March 2004CS 200 Spring Counter in Scheme using let (define (make-ocounter) (let ((count 0)) (lambda (message) (if (eq? message 'reset) (set! count 0) (if (eq? message 'next) (set! count (+ 1 count)) (if (eq? message 'how-many) count))))))

15 March 2004CS 200 Spring Defining ask > (ask bcounter 'how-many) 0 > (ask bcounter 'next) > (ask bcounter 'how-many) 1 (ask Object Method) (define (ask object message) (object message))

15 March 2004CS 200 Spring Who was the first object-oriented programmer?

15 March 2004CS 200 Spring By the word operation, we mean any process which alters the mutual relation of two or more things, be this relation of what kind it may. This is the most general definition, and would include all subjects in the universe. Again, it might act upon other things besides number, were objects found whose mutual fundamental relations could be expressed by those of the abstract science of operations, and which should be also susceptible of adaptations to the action of the operating notation and mechanism of the engine... Supposing, for instance, that the fundamental relations of pitched sounds in the science of harmony and of musical composition were susceptible of such expression and adaptations, the engine might compose elaborate and scientific pieces of music of any degree of complexity or extent. Ada, Countess of Lovelace, around 1830

15 March 2004CS 200 Spring Charge PS6: –Programming with Objects Monday: Subtyping