-
Notifications
You must be signed in to change notification settings - Fork 0
/
go_the_path_to_1_1.slide
156 lines (104 loc) · 4.49 KB
/
go_the_path_to_1_1.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
The Path to Go 1.1
language, stdlib, tools, and performance
19:00 28 Mar 2013
Tags: go1.1, go
Jesse Szwedko
Software Engineer, ModCloth
j.szwedko@modcloth.com
@jesse_szwedko
Sheena McCoy
Software Engineer, ModCloth
sp.mccoy@modcloth.com
@sheenapmccoy
* The Path to Go 1.1
- Language Changes
- Standard Library Changes
- Tool Chain Changes
- Backwards "Incompatible" Changes
- Performance
* Language Changes
* Method Value
Functions that have been bound to a specific receiver value
func (w io.Writer) Write(p []byte) (n int, err error)
.play methods_simple.go /START OMIT/,/END OMIT/
Useful for passing struct methods to APIs requiring a callback.
E.g. http.ServeMux.ServeHTTP
func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request))
Previously this would require wrapping in an anonymous function.
* Method Value
.play methods.go /START OMIT/,/END OMIT/
* Return Requirements
Functions ending in [[http://tip.golang.org/ref/spec#Terminating_statements][terminating statements]] no longer require a panic() or return
.play returns.go /START OMIT/,/END OMIT/
You can use `go vet` to find unreachable code
* Other Language Changes
Integer division by zero
- Now a compile time error
.play zero.go /START OMIT/,/END OMIT/
Surrogate halves in Unicode (UTF-16) literals
- Unicode constants with half surrogates are compile time errors
- When encoded as UTF-8 bytes, results in uft8.RuneError when decoding characters
.play surrogates.go /START OMIT/,/END OMIT/
* Standard Library Changes
* reflect.MakeFunc
Allows for implementation of pseudo-generic functions with type safety with respect to the user application.
func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value
Execution of generated function
- converts its arguments to a list of Values args.
- runs results := fn(args).
- returns the results as a slice of Values, one per formal result.
* reflect.MakeFunc
.play reflect.go /START OMIT/,/END OMIT/
* reflect.Select
Allows for dymanic generation of [[http://tour.golang.org/#62][select]] statements
const (
_ SelectDir = iota
SelectSend // case Chan <- Send
SelectRecv // case <-Chan:
SelectDefault // default
)
type SelectCase struct {
Dir SelectDir // direction of case
Chan Value // channel to use (for send or receive)
Send Value // value to send (for send)
}
func Select(cases []SelectCase) (chosen int, recv Value, recvOK bool)
* Muxing Select Go 1
.play pre-select.go /START OMIT/,/END OMIT/
* Muxing Select Go 1.1 (reflect.Select)
.play post-select.go /START OMIT/,/END OMIT/
* Muxing in Newsqueak
.code newsqueak-select.ns
Maybe someday.
[[http://www.youtube.com/watch?v=hB05UFqOtFA][CSP in Newsqueak]]
*
.iframe http://tip.golang.org/doc/go1.1#minor_library_changes 600 1000
* Tool Chain Changes
go build
- Has more detailed error messages, including paths searched for missing packages
go get
- $GOPATH requirement
- $GOPATH != $GOROOT
go test
- Leaves binaries while profiling
- Can generate profiling information about when/where go routines are blocked with -blockprofile
go fix
- Only updates 1.0 -> 1.1 code. Use go 1.0 tool chain to update pre-1.0 -> 1.0
* Backwards "Incompatible" Changes
- Ints are now 64-bit on 64-bit platforms
- UTF-16 surrogate half values are correctly considered illegal
- Assembly functions need to be revised to adjust frame pointer offsets (use go vet)
- Division by constant 0 is a compile-time error instead of runtime
- [[http://golang.org/pkg/net/][net]] package structs now have a Zone field which breaks untagged struct literals (use go fix)
- [[http://golang.org/pkg/time/][time]] package now returns nanosecond precision
- GC tool chain now uses same command-line flag parsing rules as [[http://golang.org/pkg/flag/][flag]] package
- [[http://golang.org/doc/go1compat.html][Go Compatibility]]
* Performance
Typical improvements relative to Go 1.0 seem to be about 30%-40%
- gc compiler improvements including more in-lining (including append and interface conversions)
- Re-implementation of Go maps as hashtable with buckets
- Garbage collector is more precise at the expense of CPU, but also more parallel
- Improved network performance due to tighter coupling of run-time and network libraries (fewer context switches)
* Current State of 1.1 Release
.link http://blog.golang.org/2013/03/the-path-to-go-1.html "in the coming weeks."
.iframe http://swtch.com/~rsc/go11.html 500 1000