Emerging Languages Camp 2010
Emerging Languages Camp 2010
org
Thursday, July 22, 2010
Go
Rob Pike
Emerging Languages
OSCON
July 21, 2010
http://golang.org
Thursday, July 22, 2010
Concurrency
Where did Go's concurrency model come from?
Communication is I/O.
Parallel composition is multiprocessing.
That's all you need!
More ideas in this paper than in any other 10 good papers you
are likely to find.
Communication is synchronization.
Each command can succeed or fail.
5
DISASSEMBLE::
*[cardimage:(1..80)character; cardfile?cardimage !
i:integer; i := 1;
*[i≤80 ! X!cardimage(i); i := i+1]
X!space ]
ASSEMBLE:: lineimage(1..125)character;
i:integer; i := 1;
*[c:character; X?c !
lineimage(i) := c;
[ i≤24 ! i := 1+1
[] i=125 ! lineprinter!lineimage; i := 1
] ];
[ i=1 ! skip;
[] i>1 ! *[i≤125 ! lineimage(i) := space; i := i+1];
lineprinter!lineimage ]
[west::DISASSEMBLE||COPY||east::ASSEMBLE] # pipe!
6
Can write a prime sieve for 1000 primes but not N primes; a
matrix multiplier for 3x3 but not NxN, etc. (Arrays of
processes do the bookkeeping.)
Communication synchronizes
No sharing of memory
11
12
13
x: int = 1
x := 1
15
c: chan of int;
cc: chan of chan of int;
18
19
Garbage-collected, naturally.
go disassemble(cardreader, chars1)
go copy(chars1, chars2)
21
go assemble(chars2, lineprinter)
Thursday, July 22, 2010
Summary
Go's concurrency structures have a long history dating back
to a branch in the CSP family tree in the 1980s. Multiple real
languages have built on CSP's ideas.
22
http://golang.org
23
24
25
http://golang.org
Thursday, July 22, 2010