-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhygo.slide
123 lines (82 loc) · 2.23 KB
/
whygo.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Why Go?
27 Aug 2016
Vladislav Mitov
Miracl
vladislav.mitov@gmail.com
@VladislavMitov
* Go is...
- general-purpose programming language
- open source
- developed at Google
.play hello.go
* Go is used by...
- Google, YouTube
- Facebook, Twitter
- Docker
- Uber, Hailo
- eBay
- GitHub
- Netflix
- SoundCloud
- SpaceX
- *MIRACL*
* Guiding principles in the design
.image gopher.jpg
* Go has simple syntax
- only 25 keywords (C - 35, Java - 50)
- only one loop type - for
- no fricking semicolons (;)
- no classes
.play for.go /^func main/,
* Go doesn't break backwards compatibility
- 5 years
- 7 point versions
- no backwards incompatible changes in the API
* No exception
- exceptions are slow
- piratically forces you to handle them
* Protects developers from making mistakes
- no pointer arithmetics
- no functions that hide complexity
- no unused imports
- no unused variables
* Fast compilation time
- clever dependency analysis
- compile-time error on unused dependencies
- can be used as interpreted language
* Tool chain
- go run
- go get - works with github.com, no PyPi, RubyGems, npm
- go fmt - defines and enforces consistent style
- many more
* go static analysis tools
- go vet
- go race detection
* Static linking
- produces statically linked binaries
- runs in scratch containers
* Cross compilation
* Interfaces
- implicit (types doesn't need to say what they implement) - decouples the implementation packages from the packages that define the interfaces
- lightweight - only one or two methods, in fact the most common interface in the language has zero methods
* Example from our own Miracl cryptography go implementations
- go/io
.code reader.go
* Example from our own Miracl cryptography go implementations
.code rng.go
* Example from our own Miracl cryptography go implementations
.play rng_example.go
* Concurrency
- NOT parallelism
- goroutines and channels
- say 'go' and any function goes async
- no callbacks (if not needed)
* Simple Producer-Consumer example
.play concurrency.go /^var msgs/,
* Is Go good for applications that have to be scalable?
- easy to write
- easy to read and maintain
- rich support for concurrency
- builds to a binary
- builds, starts and runs fast
- remember those scratch containers