David Evans http://www.cs.virginia.edu/evans Class 20: Objects I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. — Alan.

Slides:



Advertisements
Similar presentations
Cryptography in World War II Jefferson Institute for Lifelong Learning at UVa Spring 2006 David Evans Class 2: The Lorenz Cipher and the Postman’s Computer.
Advertisements

23-Apr-15 Abstract Data Types. 2 Data types I We type data--classify it into various categories-- such as int, boolean, String, Applet A data type represents.
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.
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.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 9: Cryptography.
Cs1120 Fall 2009 David Evans Lecture 19: Stateful Evaluation.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 12: Subtyping and Inheritance.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 12: Decrypting Work Circle Fractal.
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.
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.
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.
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.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 18: Mutation M. C. Escher, Day and.
CS100A, Lecture 13, 15 October CS100A Lecture Oct Discussion of Prelim 2 (Tuesday, 20 October, 7:30-9PM) Rooms for Prelim 2 A-K: Hollister.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 22: Objects I invented the term Object-
Lecture 3: Rules of Evaluation CS150: Computer Science
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.
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.
(Thunking about Thunks)
Praktische Informatik 1
Lecture 4: Metacircles Eval Apply David Evans
OOP - Object Oriented Programming
LCC 2700: Intro to Computational Media
Lecture 6: Lambda Calculus
Key words: Cryptography | Binary | Cipher
Introduction To Repetition The for loop
Lecture 4: Evaluation Rules Recursion CS200: Computer Science
Class 22: Inheritance CS150: Computer Science University of Virginia
CS 326 Programming Languages, Concepts and Implementation
(Tuesday, 20 October, 7:30-9PM) Encryption-Decryption
Lambda Calculus Revisited
Teaching design techniques to design efficient solutions to problems
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Class 19: Think Globally, Mutate Locally CS150: Computer Science
Methods The real power of an object-oriented programming language takes place when you start to manipulate objects. A method defines an action that allows.
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Lecture 21: Inheritance CS200: Computer Science University of Virginia
The Metacircular Evaluator
Lecture 11: All Sorts CS200: Computer Science University of Virginia
Lecture 28: Types of Types
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 12/25/2018.
Lecture 25: Metalinguistics > (meval '((lambda (x) (* x x)) 4)
6.001 SICP Environment model
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
Class 33: Making Recursion M.C. Escher, Ascending and Descending
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 2/23/2019.
6.001 SICP Environment model
JavaScript objects, functions, and events
6.001 SICP Environment model
CPSC 121: Models of Computation
Lecture 3: Rules of Evaluation CS200: Computer Science
Let’s Talk about… Smalltalk.
CPSC 121: Models of Computation
Lecture 23: Computability CS200: Computer Science
Lecture 25: The Metacircular Evaluator Eval Apply
Presentation transcript:

David Evans http://www.cs.virginia.edu/evans Class 20: Objects I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. — Alan Kay CS150: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans

Menu A better counter Finishing Fish Programming with Objects

nextx from Class 18 (define x 0) (define (nextx) (set! x (+ x 1)) x) 24 global environment + : #<primitive:+> nextx: x : 24 parameters: body: (begin (set! x (+ x 1)) x)

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?

Recall from Lecture 19: Application Construct a new frame, enclosed in the environment of this procedure Make places in that frame with the names of each parameter Put the values of the parameters in those places Evaluate the body in the new environment

A Better Counter (define (make-counter) ((lambda (count) (lambda () (set! count (+ 1 count)) count)) 0))

2 1 3 (define (make-counter) ((lambda (count) (lambda () (set! count (+ 1 count)) count)) 0)) global environment + : #<primitive:+> make-counter: mycount: > (define mycount (make-counter)) > (mycount) 1 2 3 count : 2 1 3 parameters: body: ((lambda … parameters: body: (lambda () (set! count …)

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

Using Counter > (define bcounter (make-ocounter)) > (bcounter 'next) > (bcounter 'how-many) 3 > (bcounter 'reset)

Objects When we package state and procedures together we have an object Programming with objects is object-oriented programming

Finishing Fish

Recap (through class 17) May 1941: Nazis start using Lorenz cipher to communicate between conquered European capitals Allies know Baudot code, 2 sets of 5 wheels from test messages August 1941: Operator retransmits message (with abbreviations) Allies learn one 4000-character key by XORing intercepted messages and then guessing possible plaintexts to find a pair that makes sense ~Feb 1942: Bill Tutte determines structure of Lorenz machine by analyzing key

Double Delta Combine two channels:  Z1,i XOR  Z2,I = Message is in German, more likely following letter is a repetition than random Combine two channels:  Z1,i XOR  Z2,I =  M1,i XOR  M2,i XOR  X1,i XOR  X2,i XOR  S1,i XOR  S2,i > ½ = ½ (key) > ½ S-wheels only turn some of the time (when M-wheel is 1) Prob[ Z1,i XOR  Z2,i XOR  X1,i XOR  X2,i = 0] = 0.55 So, if guess of initial configuration is correct, generated X will have this property and we will see more 0s than 1s

Using the Advantage If the guess of X is correct, should see higher than ½ of the double deltas are 0 Try guessing different configurations to find highest number of 0 double deltas Problem: # of double delta operations to try one config = length of Z * length of X = for 10,000 letter message = 12 M for each setting * 7 XOR per double delta = 89 M XOR operations

Heath Robinson Dec 1942: Decide to build a machine to do these XORs quickly, due June 1943 Apr 1943: first Heath Robinson machine is delivered! Intercepted ciphertext on tape: 2000 characters per second (12 miles per hour) Needed to perform 7 XOR operations each ½ ms Heath Robinson, British Cartoonist (1872-1944)

Colossus Heath Robinson machines were too slow Colossus designed and first built in Jan 1944 Replaced keytext tape loop with electronic keytext generator Speed up ciphertext tape: 5,000 chars per second = 30 mph Perform 5 double deltas simultaneously Speedup = 2.5X for faster tape * 5X for parallelism

Electronic Keytext Generator Colossus Design Ciphertext Tape Electronic Keytext Generator Logic Tape Reader Counter Position Counter Printer

Colossus 10 Colossi machines operating by end of WWII Decoded messages (63M letters total) that enabled Allies to know German troop locations to plan D-Day Destroyed after war, kept secret until 1970s, documents released in late 90s

Object-Oriented Programming

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

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

XEROX Palo Alto Research Center (PARC) 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

Dynabook, 1972 (Just a model) “Don’t worry about what anybody else is going to do… The best way to predict the future is to invent it. Really smart people with reasonable funding can do just about anything that doesn't violate too many of Newton's Laws!” — Alan Kay, 1971 Dynabook, 1972 (Just a model)

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

BYTE Magazine, August 1981

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”

Counter in Smalltalk class name counter instance variable names count new count <- 0 next count <- count + 1 how-many ^ count

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

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

Defining ask (define (ask object message) (object message)) (ask Object Method) > (ask bcounter 'how-many) > (ask bcounter 'next) 1 (define (ask object message) (object message))

Who was the first object-oriented programmer?

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

Charge Alan Kay talk at UVa! Wednesday (and PS6): “Children as Digital Scholars” Wednesday, 10am Newcomb Hall South Meeting Room Wednesday (and PS6): Programming with objects Inheritance