Go Programming
Go Programming
Go Programming
http://bit.ly/go2010io
*Sometimes we'll use Java as a reference for comparison but we could make the
same points comparing Go to a number of other languages.
fmt.Println(newVal("2").BinaryOp("+", newVal("4")).String())
10
15
17
18
19
20
You can use this approach in Java but it's not usual Java style.
Java (like many languages) puts type inheritance first.
21
22
24
25
becomes
func sendResponse(sending *sync.Mutex, req *Request,
reply interface{}, enc ServerCodec, errmsg string)
27
29
30
// cipher feedback
func NewCFBDecrypter(c Cipher, s int, iv []byte, r io.Reader)
io.Reader
// output feedback
func NewOFBReader(c Cipher, iv []byte, r io.Reader) io.Reader
Blowfish CBC?
r = block.NewCBCDecrypter(blowfish.NewCipher(key), iv, r)
In short:
- parallelism is about performance
- concurrency is about program design
34
In real life we'd distribute work across many machines, but for
simplicity we'll just focus on a local load balancer.
35
36
Balancer
To Requester To Requester
Worker Worker Worker Worker
37
38
41
With very little work, you could use network channels or RPCs
to make this a distributed, networked load balancer. (Although
closures don't work across the network, RPCs help.)
44
46
More at http://golang.org
47
48
http://bit.ly/go2010io
49