Professional Documents
Culture Documents
of Computer Programming
Peter Van Roy
Universit catholique de Louvain
Louvain-la-Neuve, Belgium
Seif Haridi
Kungliga Tekniska Hgskolan
Kista, Sweden
9/12/2004
Overview
Concepts-based approach
History
Creative extension principle
Teaching programming
Examples to illustrate the approach
What is programming?
Concurrent programming
Data abstraction
Graphical user interface programming
Object-oriented programming: a small part of a big world
Formal semantics
Conclusion
9/12/2004
9/12/2004
What is programming?
9/12/2004
Concepts-based approach
9/12/2004
History (1)
9/12/2004
History (2)
9/12/2004
Both were already known in the 1970s, but largely ignored afterward!
P. Van Roy, BCS talk
9/12/2004
Example of
creative extension principle
Language
without exceptions
Error treated here
All procedures on
path are modified
Language
with exceptions
Error treated here
proc {P1 }
try
{P2 }
catch E then end
end
proc {P2 }
{P3 }
end
Unchanged
Only procedures at
ends are modified
proc {P3 }
{P4 }
end
proc {P4 }
if (error) then
raise myError end
end
end
Taxonomy of paradigms
Declarative programming
Strict functional programming, Scheme, ML
Concurrent OOP
(message passing, Erlang, E)
(shared state, Java)
+ computation spaces
Constraint programming
10
Empty statement
Variable binding
Value creation
Sequential composition
Variable creation
Conditional
Pattern matching
Procedure invocation
Thread creation
By-need synchronization
{NewName <x>}
<x>1= !!<x>2
try <s>1 catch <x> then <s>2 end
raise <x> end
{NewPort <x>1 <x>2}
{Send <x>1 <x>2}
Name creation
Read-only view
Exception context
Raise exception
Port creation
Port send
<space>
Encapsulated search
9/12/2004
11
Empty statement
Variable binding
Value creation
Sequential composition
Variable creation
Conditional
Pattern matching
Procedure invocation
Thread creation
By-need synchronization
{NewName <x>}
<x>1= !!<x>2
try <s>1 catch <x> then <s>2 end
raise <x> end
{NewCell <x>1 <x>2}
{Exchange <x>1 <x>2 <x>3}
Name creation
Read-only view
Exception context
Raise exception
Cell creation
Cell exchange
<space>
Encapsulated search
9/12/2004
Alternative
12
Teaching programming
9/12/2004
13
No!
9/12/2004
14
9/12/2004
15
9/12/2004
16
9/12/2004
17
Declarative programming,
concurrency, and multi-agent systems
9/12/2004
Declarative
programming
+ threads
Declarative
concurrency
+ ports
Message-passing
concurrency
18
Declarative
programming
+ cells
+ threads
Stateful
Declarative
programming
and
data abstraction
concurrency
and
agents
9/12/2004
19
+ threads
programming
Declarative
concurrency
Declarative
+ ports
+ cells
Message-passing
Shared-state
concurrency
concurrency
9/12/2004
20
Concurrent programming
Data abstraction
Graphical user interface programming
Object-oriented programming in a wider framework
9/12/2004
21
Concurrent programming
9/12/2004
22
Example of
declarative concurrency
Xs
Prod
local Xs in
thread Xs={Prod 0 1000} end
thread {Cons Xs} end
end
9/12/2004
Cons
23
Data abstraction
9/12/2004
24
9/12/2004
25
9/12/2004
26
Stateful ADT
Pure object
The usual one!
Stateless
Pure ADT
Declarative object
bundling
Abstract
data type
9/12/2004
Object
27
9/12/2004
28
Mixed declarative/imperative
approach to GUI design
9/12/2004
29
Example GUI
{Build W}
{E set(text:Type here)}
Result={E get(text:$)}
P. Van Roy, BCS talk
30
W=placeholder(handle:P)
{P set( label(text:Hello) )}
{P set( entry(text:World) )}
Any GUI specification can be put in the placeholder at runtime (the spec is a data structure that can be calculated)
9/12/2004
31
Object-oriented programming:
a small part of a big world
9/12/2004
32
Formal semantics
9/12/2004
33
9/12/2004
34
Abstract machine
9/12/2004
Full
language
Remove syntax
Kernel
language
Execute
Abstract
machine
35
9/12/2004
proc {Fact N F}
local B in
B=(N==0)
if B then F=1
else
local N1 F1 in
N1=N-1
{Fact N1 F1}
F=N*F1
end
end
end
end
36
Syntax of a simple
kernel language (1)
skip
<x>1=<x>2
<x>=<v>
local <x> in <s> end
if <x> then <s>1 else <s>2 end
{<x> <x>1 <x>n}
case <x> of <p> then <s>1 else <s>2 end
<v> ::=
<p> ::=
9/12/2004
37
Syntax of a simple
kernel language (2)
9/12/2004
38
Environment E = {X x, Y y}
9/12/2004
39
Sn
stack
9/12/2004
(<s>,E+{X x})
S2
{x}
Sn
store
P. Van Roy, BCS talk
stack
store
40
The if statement
9/12/2004
41
Procedures (closures)
9/12/2004
42
9/12/2004
43
Conclusions
9/12/2004
44