64
The Power of Abstraction Barbara Liskov October 2009

The Power of Abstraction Barbara Liskov October 2009

Embed Size (px)

Citation preview

Page 1: The Power of Abstraction Barbara Liskov October 2009

The Power of Abstraction

Barbara LiskovOctober 2009

Page 2: The Power of Abstraction Barbara Liskov October 2009

Outline

Inventing abstract data types CLU Type hierarchy What next

Page 3: The Power of Abstraction Barbara Liskov October 2009

Data Abstraction Prehistory

The Venus machine

Page 4: The Power of Abstraction Barbara Liskov October 2009

The Interdata 3

Page 5: The Power of Abstraction Barbara Liskov October 2009

Data Abstraction Prehistory

The Venus machine The Venus operating system

Page 6: The Power of Abstraction Barbara Liskov October 2009

Data Abstraction Prehistory

The Venus machine The Venus operating system Programming methodology

Page 7: The Power of Abstraction Barbara Liskov October 2009

Programming Methodology

The software crisis! Machines were getting cheaper And bigger/faster

E. W. Dijkstra. The Humble Programmer. Cacm, Oct. 1972

Page 8: The Power of Abstraction Barbara Liskov October 2009

Programming Methodology

How should programs be designed?

How should programs be structured?

Page 9: The Power of Abstraction Barbara Liskov October 2009

The Landscape

E. W. Dijkstra. Go To Statement Considered Harmful. Cacm, Mar. 1968

Page 10: The Power of Abstraction Barbara Liskov October 2009

The Landscape

N. Wirth. Program Development by Stepwise Refinement. Cacm, April 1971

Page 11: The Power of Abstraction Barbara Liskov October 2009

The Landscape D. L. Parnas. Information

Distribution Aspects of Design Methodology. IFIP Congress, 1971

“The connections between modules are the assumptions which the modules make about each other.”

Page 12: The Power of Abstraction Barbara Liskov October 2009

The Landscape

D. L. Parnas, On the Criteria to be used in Decomposing Systems into Modules. Cacm, Dec. 1972

Page 13: The Power of Abstraction Barbara Liskov October 2009

Partitions

B. Liskov. A Design Methodology for Reliable Software Systems. FJCC, Dec. 1972

Page 14: The Power of Abstraction Barbara Liskov October 2009

Partitions

Partition state

op1 op2 op3

Page 15: The Power of Abstraction Barbara Liskov October 2009

From Partitions to ADTs

How can these ideas be applied to building programs?

Page 16: The Power of Abstraction Barbara Liskov October 2009

Idea

Connect partitions to data types

Page 17: The Power of Abstraction Barbara Liskov October 2009

Meeting in Savanah

ACM Sigplan-Sigops interface meeting. April 1973. (Sigplan Notices, Sept. 1973)

Started to work with Steve Zilles

Page 18: The Power of Abstraction Barbara Liskov October 2009

The Landscape

Extensible Languages S. Schuman and P. Jourrand.

Definition Mechanisms in Extensible Programming Languages. AFIPS. 1967

R. Balzer. Dataless Programming. FJCC 1967

Page 19: The Power of Abstraction Barbara Liskov October 2009

The Landscape

O-J. Dahl and C.A.R. Hoare. Hierarchical Program Structures. Structured Programming, Academic Press, 1972

Page 20: The Power of Abstraction Barbara Liskov October 2009

The Landscape

J. H. Morris. Protection in Programming Languages. Cacm. Jan. 1973

Page 21: The Power of Abstraction Barbara Liskov October 2009

The Landscape

W. Wulf and M. Shaw. Global Variable Considered Harmful. Sigplan Notices. Feb. 1973.

Page 22: The Power of Abstraction Barbara Liskov October 2009

Abstract Data Types B. Liskov and S. Zilles.

Programming with Abstract Data Types. ACM Sigplan Conference on Very High Level Languages. April 1974

Page 23: The Power of Abstraction Barbara Liskov October 2009

What that paper proposed

Abstract data types A set of operations And a set of objects The operations provide the only way

to use the objects

Page 24: The Power of Abstraction Barbara Liskov October 2009

What that paper proposed

Abstract data types Clusters with encapsulation

Polymorphism Static type checking (we hoped) Exception handling

Page 25: The Power of Abstraction Barbara Liskov October 2009

From ADTs to CLU

Participants Russ Atkinson Craig Schaffert Alan Snyder

Page 26: The Power of Abstraction Barbara Liskov October 2009
Page 27: The Power of Abstraction Barbara Liskov October 2009

Why a Programming Language?

Communicating to programmers Do ADTs work in practice? Getting a precise definition Achieving reasonable performance

Page 28: The Power of Abstraction Barbara Liskov October 2009

Language Design

Goals Ease of use Simplicity Expressive power Performance

Page 29: The Power of Abstraction Barbara Liskov October 2009

Language Design

More goals Minimality Uniformity Safety

Page 30: The Power of Abstraction Barbara Liskov October 2009

Some Assumptions/Decisions

Heap-based with garbage collection!

No block structure! Separate compilation Static type checking

Page 31: The Power of Abstraction Barbara Liskov October 2009

More Assumptions/Decisions

No concurrency No go tos No inheritance

Page 32: The Power of Abstraction Barbara Liskov October 2009

CLU Mechanisms

Clusters Polymorphism Exception handling Iterators

Page 33: The Power of Abstraction Barbara Liskov October 2009

Clusters

IntSet = cluster is create, insert, delete, isIn, …

end IntSet

Page 34: The Power of Abstraction Barbara Liskov October 2009

Clusters

IntSet = cluster is create, insert, delete, …end IntSet

IntSet s := IntSet$create( )IntSet$insert(s, 3)

Page 35: The Power of Abstraction Barbara Liskov October 2009

Clusters

IntSet = cluster is create, insert, delete, …

rep = array[int]

Page 36: The Power of Abstraction Barbara Liskov October 2009

Clusters

IntSet = cluster is create, insert, delete, …

rep = array[int]

create = proc ( ) returns (cvt) return (rep$create( )) end create

Page 37: The Power of Abstraction Barbara Liskov October 2009

Polymorphism

Set = cluster[T: type] is create, insert, …

end Set

Set[int] s := Set[int]$create( )Set[int]$insert(s, 3)

Page 38: The Power of Abstraction Barbara Liskov October 2009

Polymorphism

Set = cluster[T: type] is create, insert, … where T has equal: proctype(T, T) returns (bool)

Page 39: The Power of Abstraction Barbara Liskov October 2009

Polymorphism

Set = cluster[T: type] is create, insert, … where T has equal: proctype(T, T) returns (bool)

rep = array[T]

insert = proc (x: cvt, e: T) … if e = x[i] then …

Page 40: The Power of Abstraction Barbara Liskov October 2009

Exception Handling

J. Goodenough. Exception Handling: Issues and a Proposed Notation. Cacm, Dec. 1975 Termination vs. resumption How to specify handlers

Page 41: The Power of Abstraction Barbara Liskov October 2009

Exception Handling

choose = proc (x: T) signals (empty)

if rep$size() = 0 then signal empty …

Page 42: The Power of Abstraction Barbara Liskov October 2009

Exception Handling

choose = proc (x: T) signals (empty)

if rep$size() = 0 then signal empty …

set[T]$ choose() except when empty: …

Page 43: The Power of Abstraction Barbara Liskov October 2009

Exception Handling

Handling Propagating Shouldn’t happen

The failure exception Principles

Accurate interfaces Avoid useless code

Page 44: The Power of Abstraction Barbara Liskov October 2009

Iterators

For all x in C do S

Page 45: The Power of Abstraction Barbara Liskov October 2009

Iterators

For all x in C do S Destroy the collection? Complicate the abstraction?

Page 46: The Power of Abstraction Barbara Liskov October 2009

Visit to CMU

Bill Wulf and Mary Shaw, Alphard Generators

Page 47: The Power of Abstraction Barbara Liskov October 2009

Iterators

sum: int := 0for x: int in Set[int]$members(s) do sum := sum + x end

Page 48: The Power of Abstraction Barbara Liskov October 2009

Iterators

Set = cluster[T] is create, …, members, …

rep = array[T]

members = iter (x: cvt) yields (T) for z: T in rep$elements(x) do yield (z) end

Page 49: The Power of Abstraction Barbara Liskov October 2009

After CLU

Argus and distributed computing Type Hierarchy

Page 50: The Power of Abstraction Barbara Liskov October 2009

The Landscape

Inheritance was used for: Inplementation Type hierarchy

Page 51: The Power of Abstraction Barbara Liskov October 2009

Implementation Inheritance

Violated encapsulation!

Page 52: The Power of Abstraction Barbara Liskov October 2009

Type hierarchy

Wasn’t well understood E.g., stacks vs. queues

Page 53: The Power of Abstraction Barbara Liskov October 2009

The Liskov Substitution Principle (LSP)

Objects of subtypes should behave like those of supertypes if used via supertype methods

B. Liskov. Data abstraction and hierarchy. Sigplan notices, May 1988

Page 54: The Power of Abstraction Barbara Liskov October 2009

Polymorphism

where T has … vs. where T subtype of S

Proofs happen at different times!

Page 55: The Power of Abstraction Barbara Liskov October 2009

What Next?

Modularity based on abstraction is the way things are done

Page 56: The Power of Abstraction Barbara Liskov October 2009

Modern Programming Languages

Are good!

Page 57: The Power of Abstraction Barbara Liskov October 2009

Missing Features

Procedures are important And closures and iterators Exception handling Built-in types

Can’t we do better for “serialization”?

Page 58: The Power of Abstraction Barbara Liskov October 2009

The state of programming Isn’t great! Especially web services and

browsers Return of globals

Page 59: The Power of Abstraction Barbara Liskov October 2009

An aside: persistent storage typically violates abstraction

E.g., a file system or a database It’s a big space of globals! Without support for encapsulation An object store would be much

better Automatic translation Type preservation

Page 60: The Power of Abstraction Barbara Liskov October 2009

Programming language research

New abstraction mechanisms? Concurrency

Multi-core machines Distributed systems?

Page 61: The Power of Abstraction Barbara Liskov October 2009

Systems research

Has done well Distributed hash tables Map-reduce Client/server Distributed information flow …

Page 62: The Power of Abstraction Barbara Liskov October 2009

A Concern

Performance isn’t the most important issue vs. semantics vs. simplicity

E.g., one-copy consistency Failures should be catastrophes

Page 63: The Power of Abstraction Barbara Liskov October 2009

Systems Problems

Internet Computer Storage and computation Semantics, reliability, availability,

security Massively parallel machines

Page 64: The Power of Abstraction Barbara Liskov October 2009

The Power of Abstraction

Barbara LiskovOctober 2009