-
Notifications
You must be signed in to change notification settings - Fork 2
/
go-talk-all.slide
89 lines (57 loc) · 2.25 KB
/
go-talk-all.slide
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
What is Go?
A quick tour
12 Apr 2016
Tags: oss, lang, systems programming
Josh Finken
Reality Capture and Processing, HERE
* Quick Overview of:
- History and Semantics
- Composition over Inheritance
- Concurrency
- Tools and Dev Environments
- Who's Using Go
* History and Semantics
- Conceived late 2007 at Google. Rob Pike, Ken Thompson.
- Write, read, debug and maintain large software systems.
- Designed for scale: large programs with large numbers of dependencies, large numbers of programmers.
- Goal: be productive now with large software systems.
* Semantics
- Procedural, of the C-family, modern.
- Compiled, statically typed.
- No pointer arithmetic!
- Concurrency: native, robust, simple approach at the language level.
- Garbage-collected.
* As of Go 1.6: ~3ms GC pause time [1]:
.image images/gcgotip.png
.link http://talks.golang.org/2016/state-of-go.slide#38 [1] The State of Go
* Composition over Inheritance:
- No concept of class inheritance: no _inherits_, _implements_, nor _extends_ keywords
- Structural (aka duck) typing: _interface_
- Create abstractions by considering the _behavior_ that is common between datatypes
.code interface_animal.go
* A more real-world example with io:
.code interface_from_package_io.go
* A more real-world example with io:
.play interface_readwriter.go
* Compose: embedding
- A type can be embedded in another type
- Akin to "super" being called automatically
.code compose_structs.go /START1 OMIT/,/END1 OMIT/
* Compose:
- Field and methods are promoted
.code compose_structs.go /START2 OMIT/,/END2 OMIT/
* Concurrency
- Native simple approach at the language level: _goroutine_
- Akin to lightweight threads.
- Are a variant of [[https://en.wikipedia.org/wiki/Communicating_sequential_processes][Communicating Sequential Processes]], a dual of the Actor model.
- Message-passing through a non-buffered channel: rendezvous point
- Message-passing through a buffered channel: asynchronous
* Concurrency: goroutines
.play concurrency_goroutine.go
* Concurrency: channels
.play concurrency_channels.go
* Concurrency: buffered channels
- Sends to a buffered channel block only when the buffer is full.
- Receives block when the buffer is empty.
.play concurrency_buffered_channels.go