Title: Kahn Networks at the Dawn of Functional Programming
1Kahn Networks at the Dawn of Functional
Programming
- David MacQueen
- University of Chicago
2Kahn Networks
The Semantics of a Simple Language for Parallel
Programming
IFIP 1974
3At work in Versailles
4Example A Process
Process f(integer in U,V integer out U)
Begin integer I logical B B true
Repeat Begin I if B then
wait(U) else wait(V) print(I)
send I on W B B
End End
5A Program
Begin Integer channel X, Y, Z, T1, T2
Process f(integer in U,V integer out U)
Begin ... End Process g(integer in U integer
out V,W) Begin ... End Process h(integer
in U integer out V integer INIT) Begin ...
End f(Y,Z,X) par g(X,T1,T2) par h(T1,Y,0) par
h(T2,Z,1) End
6The Network
7Background, Sources
- Parallel programming for OS
- Balzers ISPL, Brinch Hansen, Lauer, OS 360 (not
yet Unix!) - Scott Domains, denotational semantics
- Proof techniques for recursive programs
- Scott, deBakker, Manna, Vuillemin, Milner, ...
8Semantics
Represent channel histories as streams Represent
processes as stream functions Streams (over data
D) D?, the CPO of finite and infinite
sequences under prefix ordering Primitive stream
operations A(ppend) F(irst) R(est)
cons () hd tl
9Processes as Functions
f(U,V) hd(U) hd(V) f(tl(U),tl(V)) g1(U)
hd(U) g1(tl(tl(U))) g2(U) hd(tl(U))
g2(tl(tl(U))) h(U,x) x U
10Network as Recursive Eqns
X f(Y,Z) Y h(T1,0) Z h(T2,1) T1 g1(X) T2
g2(X)
X f(h(g1(X),0), h(g2(X),1))
X 0 1 f(g1(X),g2(X))
X 0 1 X
11Network semantics
channels gt streams processes gt
continuous functions on streams networks gt
systems of recursive stream equations network
behavior gt least fixed point of network
equations
12Lazy Functional Programming!
Although IFIP74 says little about scheduling or
evaluation strategy, the fixed point semantics
with reified streams implies lazy
evaluation. The functional form of network
programs may well be the first pure, lazy
functional language.
13Observations on IFIP74
- Semantics and proof as major desiderata in design
- Advantages of a pure model we see the essential
merit as the eradication of the notion of state
of a complex system. - Language is deterministic. Adding nondeterminism
through a select primitive is suggested but not
developed.
14Implementation and Experimentation
Coroutines and Networks of Parallel
Processes Kahn and MacQueen IFIP 77
15POP-2 Implementation
- Early 1976, I investigate coroutines in POP-2
using state-saving, a rudimentary control
operator related to first-class continuations
(later this is superseded by real coroutines,
called processes.) - Gilles and I discuss using this to implement his
stream processing language, and I do so. - result is a version of the imperative process
language embedded in POP-2 and using POP-2 syntax.
16Explorations
- Sieve of Eratosthenes
- Hamming problem
- Power series
- Sorting algorithms
- Infinite precision real numbers
- Discrete Fourier transform
17Language evolution
Language evolves toward the functional form.
start doco OUTPUTF(20,X) where channels X,Y,Z
are QCONS(1,MERGE(TIMES(2,X),Y)),
QCONS(3,MERGE(TIMES(3,Y),Z)),
QCONS(5,TIMES(5,Z)) closeco
let rec X 1MERGE(TIMES(2,X),Y) and Y
3MERGE(TIMES(3,Y),Z) and Z 5TIMES(5,Z)
in X
18IFIP 77 Connections
Conway coroutines, 1963 Milner processes, 1973
(virtual streams) Landin functional streams 1965
(virtual streams) McIlroy coroutines, sieve
example, 1968 POP-2 generator functions and
dynamic lists, 1968 McIlroy Unix pipe,
1970 Lucid, Ashcroft Wadge, July 1975 (Arc et
Senans) Concrete Domains Kahn Plotkin 1975
... Lazy evaluation in LISP, Henderson Morris,
Jan 1976 Lazy evaluation in LISP, Friedman
Wise, July 1976
19Impact and Influence
- Many variations have been studied
- Languages and language features have been
inspired (e.g. reactive languages) - Hundreds of citations in literature
- Streams have become a standard tool
- Commonplace in lazy functional programming and
strict as well
20(No Transcript)