Form & Function in Software - Dreamsongs

79
Form & Function in Software Richard P. Gabriel phd mfa

Transcript of Form & Function in Software - Dreamsongs

Page 1: Form & Function in Software - Dreamsongs

Form & Functionin Software

Richard P. Gabriel phd mfa

Page 2: Form & Function in Software - Dreamsongs

<1>

Page 3: Form & Function in Software - Dreamsongs

Confusionists and superficial intellectuals...

Page 4: Form & Function in Software - Dreamsongs

...move ahead...

Page 5: Form & Function in Software - Dreamsongs

...while the ‘deep thinkers’ descend into the darker regions of the

status quo...

Page 6: Form & Function in Software - Dreamsongs

...or, to express it in a different way, they remain stuck in the mud.

–Paul Feyerabend

Page 7: Form & Function in Software - Dreamsongs

<2>

Page 8: Form & Function in Software - Dreamsongs

(defun factorial (n) (cond ((= n 0) 1) (t (* n (factorial (- n 1))))))

Page 9: Form & Function in Software - Dreamsongs

(defun eval (form env) (cond ((null form) nil) ((numberp form) form) ((stringp form) form) ((eq t form) form) ((atom form) (cond ((get form 'APVAL)) (t (lookup form env)))) ((eq (car form) 'quote) (car (cdr form))) ((eq (car form) 'cond) (evalcond (cdr form) env)) (t (apply (car form) (evallist (cdr form) env) env))))

(defun apply (fct parms env) (cond ((atom fct) (cond ((eq fct 'car) (car (car parms))) ((eq fct 'cdr) (cdr (car parms))) ((eq fct 'cons) (cons (car parms) (car (cdr parms)))) ((eq fct 'get) (get (car parms) (car (cdr parms)))) ((eq fct 'atom) (atom (car parms))) ((eq fct 'error) (error (string parms))) ((eq fct 'eq) (eq (car parms) (car (cdr parms)))) (t (cond ((get fct 'EXPR) (apply (get fct 'EXPR) parms env) parms env) (t (apply (lookup fct env) parms env)))))) ((eq (car fct) 'lambda) (eval (car (cdr (cdr fct))) (update (car (cdr fct)) parms env))) (t (apply (eval fct env) parms env))))

(defun evalcond (conds env) (cond ((null conds) nil) ((eval (car (car conds)) env) (eval (car (cdr (car conds))) env)) (t (evalcond (cdr conds) env))))

Page 10: Form & Function in Software - Dreamsongs

(defun eval (form env)(cond ((null form) nil) ((numberp form) form) ((stringp form) form) ((eq t form) form) ((atom form) (cond ((get form 'APVAL)) (t (lookup form env)))) ((eq (car form) 'quote) (car (cdr form))) ((eq (car form) 'cond) (evalcond (cdr form) env)) (t (apply (car form) (evallist (cdr form) env) env))))(defun apply (fct parms env) (cond ((atom fct) (cond ((eq fct 'car) (car (car parms))) ((eq fct 'cdr) (cdr (car parms))) ((eq fct 'cons) (cons (car parms) (car (cdr parms)))) ((eq fct 'get) (get (car parms) (car (cdr parms)))) ((eq fct 'atom) (atom (car parms))) ((eq fct 'error) (error (string parms))) ((eq fct 'eq) (eq (car parms) (car (cdr parms)))) (t (cond ((get fct 'EXPR) (apply (get fct 'EXPR) parms env) parms env) (t (apply (lookup fct env) parms env)))))) ((eq (car fct) 'lambda) (eval (car (cdr (cdr fct))) (update (car (cdr fct)) parms env))) (t (apply (eval fct env) parms env))))(defun evalcond (conds env) (cond ((null conds) nil) ((eval (car (car conds)) env) (eval (car (cdr (car conds))) env)) (t (evalcond (cdr conds) env))))

Page 11: Form & Function in Software - Dreamsongs

form and function can be as disjoint as you care to have it

Page 12: Form & Function in Software - Dreamsongs

(factorial 10) -> 3628800

Page 13: Form & Function in Software - Dreamsongs

(defun eval (form env) (cond ((eq form 't) t) ((eq form 1) (format t "!~%") nil) ((atom form) (lookup form env)) ((eq (car form) '*) (format t " Screw you!") (eval (caddr form) env)) ((eq (car form) '=) (= 0 (lookup (caddr form) env))) ((eq (car form) '-) (- (lookup (cadr form) env) 1)) ((eq (car form) 'cond) (evcond (cdr form) env)) (t (apply (car form) (evlist (cdr form) env) env))))

(defun apply (fn args env) (let ((fndef (lookup fn env))) (eval (cadr fndef) (update (car fndef) args env))))

(defun evcond (forms env) (cond ((null forms) nil) ((eval (car (car forms)) env) (eval (cadr (car forms)) env)) (t (evcond (cdr forms) env))))

(defun update (l1 l2 env) (cond ((null l1) env) (t (update (cdr l1) (cdr l2) (push (list (car l1) (car l2)) env)))))

(defun lookup (var env) (cadr (assoc var env)))

(defun evlist (l env) (mapcar #'(lambda (x) (eval x env)) l))

Page 14: Form & Function in Software - Dreamsongs

(factorial 10) ->

Screw you! Screw you! Screw you! Screw you! Screw you! Screw you! Screw you! Screw you! Screw you! Screw you!!NIL

Page 15: Form & Function in Software - Dreamsongs

the same form can have many functions...

Page 16: Form & Function in Software - Dreamsongs

...& the same function can be expressed in many forms

Page 17: Form & Function in Software - Dreamsongs

form1 form2

form3 form4Function

Page 18: Form & Function in Software - Dreamsongs

but, an interpreter is another form...

Page 19: Form & Function in Software - Dreamsongs

Form Function

Form Function

Interpreter1

Page 20: Form & Function in Software - Dreamsongs

Form Function

Form Function

Form Function

Interpreter1

Interpreter2

Page 21: Form & Function in Software - Dreamsongs

Form Function

Form Function

Form Function

Interpreter1

Interpreter2

Form Function

Interpreter3

Page 22: Form & Function in Software - Dreamsongs

Form Function

Form Function

Interpreter1

Page 23: Form & Function in Software - Dreamsongs

almost any number of interpreters can produce the same result

Page 24: Form & Function in Software - Dreamsongs

∀form, ∀ function, ∃ interpreter stform -[interpreter]-> function

Page 25: Form & Function in Software - Dreamsongs

in the real world...

Page 26: Form & Function in Software - Dreamsongs

form <-[laws of physics?]-> function

Page 27: Form & Function in Software - Dreamsongs

a door must be large enough...

Page 28: Form & Function in Software - Dreamsongs

...for what passes through...

Page 29: Form & Function in Software - Dreamsongs

...& a table must be flat...

Page 30: Form & Function in Software - Dreamsongs

...so what it supports does not slip

Page 31: Form & Function in Software - Dreamsongs

such laws are the essential interpreter...

Page 32: Form & Function in Software - Dreamsongs

...everything else is contingent

Page 33: Form & Function in Software - Dreamsongs

and perhaps in the real world...

Page 34: Form & Function in Software - Dreamsongs

form <-[design]- function

[design]

|^ constrained

constrained

Page 35: Form & Function in Software - Dreamsongs

form <-[design]- function

[design]

|^| ^ constrained

constrained

Page 36: Form & Function in Software - Dreamsongs

in the software world...

Page 37: Form & Function in Software - Dreamsongs

function^|

design

Page 38: Form & Function in Software - Dreamsongs

function^|

design

form^|

design

Page 39: Form & Function in Software - Dreamsongs

function^|

design

form^|

design

Page 40: Form & Function in Software - Dreamsongs

function^|

design

form^|

design

Page 41: Form & Function in Software - Dreamsongs

are all software interpreters contingent?

Page 42: Form & Function in Software - Dreamsongs

Physical Constraints on Computing

P=NP?

size and speed of memory

speed of processors

speed of communications

density of computational resources

Page 43: Form & Function in Software - Dreamsongs

limited resourcesunlimited imagination

Page 44: Form & Function in Software - Dreamsongs

...but it’s rarely this desperate...

Page 45: Form & Function in Software - Dreamsongs

<3>

Page 46: Form & Function in Software - Dreamsongs

Other Forms of Form

Model Purpose Languagesprocedural control Pascal, Algolfunctional composition Lisp, Haskelllogic constraints Prologobject-oriented simulation Smalltalk, Javahardware OS C, C++string transformation Perlarray collections APLconcurrency events threading?...

Page 47: Form & Function in Software - Dreamsongs

invent an intellectual structure...

Page 48: Form & Function in Software - Dreamsongs

...describing a programming model...

Page 49: Form & Function in Software - Dreamsongs

...that makes it easier to program things that we think of that way

Page 50: Form & Function in Software - Dreamsongs

OO: objects sending messages to each other

Page 51: Form & Function in Software - Dreamsongs
Page 52: Form & Function in Software - Dreamsongs
Page 53: Form & Function in Software - Dreamsongs
Page 54: Form & Function in Software - Dreamsongs
Page 55: Form & Function in Software - Dreamsongs
Page 56: Form & Function in Software - Dreamsongs
Page 57: Form & Function in Software - Dreamsongs

<4>

Page 58: Form & Function in Software - Dreamsongs

other forms of form

Page 59: Form & Function in Software - Dreamsongs

Johnniac

Page 60: Form & Function in Software - Dreamsongs

G5

Page 61: Form & Function in Software - Dreamsongs

Sony Personal Entertainment Communicator

Page 62: Form & Function in Software - Dreamsongs

QRIO

Page 63: Form & Function in Software - Dreamsongs

~50 computers

Page 64: Form & Function in Software - Dreamsongs

Boeing 777 Flight Deck

Page 65: Form & Function in Software - Dreamsongs

<5>

Page 66: Form & Function in Software - Dreamsongs

many excellent programs...

Page 67: Form & Function in Software - Dreamsongs

...exhibit common local characteristics...

Page 68: Form & Function in Software - Dreamsongs

...not the same, but similar...

Page 69: Form & Function in Software - Dreamsongs

...and they represent sketches of form...

Page 70: Form & Function in Software - Dreamsongs

...giving rise to

excellent function,sturdy structure,

and palpable beauty

Page 71: Form & Function in Software - Dreamsongs

they are called “patterns,”...

Page 72: Form & Function in Software - Dreamsongs

...and they are our best hope for a lasting connection between

form and function in software

Page 73: Form & Function in Software - Dreamsongs

<6>

Page 74: Form & Function in Software - Dreamsongs

form creates function for theessential interpreter

Page 75: Form & Function in Software - Dreamsongs

form creates aesthetics for thecontingent interpreter

Page 76: Form & Function in Software - Dreamsongs

software is the discipline whereform and function

are least entangled

Page 77: Form & Function in Software - Dreamsongs

last thought:

Page 78: Form & Function in Software - Dreamsongs

(factorial 10)

Page 79: Form & Function in Software - Dreamsongs

!