1 of 140

Introducing Go 1.6

Brad Fitzpatrick

@bradfitz

bradfitz@golang.org

https://www.youtube.com/watch?v=4Dr8FXs9aJM

2 of 140

Go 1.6

3 of 140

Go 1.6

Feb 2016

(couple days ago)

4 of 140

Introducing Go 1.6

Brad Fitzpatrick

@bradfitz

bradfitz@golang.org

5 of 140

Introducing Go 1.6:

asymptotically approaching boring

Brad Fitzpatrick

@bradfitz

bradfitz@golang.org

6 of 140

Introducing Go 1.6:

asymptotically approaching boring

Brad Fitzpatrick

@bradfitz

bradfitz@golang.org

7 of 140

History

And Go’s release cycle

8 of 140

Go 1.5

Aug 2015

9 of 140

Go 1.4

Dec 2014

10 of 140

Go 1.3

Jun 2014

11 of 140

Go 1.2

Dec 2013

12 of 140

Go 1.1

May 2013

13 of 140

Go 1

Mar 2012

14 of 140

Go 1.6

Feb 2016

15 of 140

Go 1.7

Aug 2016

16 of 140

Go 1.8

Feb 2017

17 of 140

Go 1.9

Aug 2017

18 of 140

Go 2.0 !!!

Feb 2018

19 of 140

Generics!

20 of 140

Sum Types!

21 of 140

List comprehensions!

22 of 140

Immutability!

23 of 140

Rationalizing

[]byte vs string

24 of 140

Rationalizing

new() vs make()

25 of 140

Rationalizing

:= vs var

26 of 140

VFS layer,

os.File becomes an interface

27 of 140

~memory

@ownership!

28 of 140

Data races statically impossible!

29 of 140

Years of mistakes revisited...

30 of 140

Tons of feature requests resolved...

31 of 140

32 of 140

YAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYAYAY

Are you excited yet!?!?

33 of 140

Sorry.

34 of 140

I lied.

35 of 140

Go 1.9

Aug 2017

36 of 140

Go 1.10

Feb 2018

37 of 140

Go 1.11

Aug 2018

38 of 140

etc.

39 of 140

So… when is Go 2?

40 of 140

No plans.

Maybe never.

41 of 140

http://brenda1eye.blogspot.com/2009_05_01_archive.html

42 of 140

http://hawkeview.blogspot.in/2010/05/great-gopher-war.html

43 of 140

https://twitter.com/jrstahl/status/591656618275819520

44 of 140

Previous Language Additions

(was it ever not boring?)

45 of 140

Go 1

Mar 2012

46 of 140

Go 1

  • append([]byte, string…)
  • disallow close on receive-only channels
  • composite literal type ellison
  • goroutines during init
  • the rune type
  • the error type (interface type in global scope!)
  • delete(m, k)
  • random map iteration order
  • struct equality
  • copying structs with unexported fields
  • ….

47 of 140

Go 1.1

May 2013

48 of 140

Go 1.1

  • method values!

type T struct { … once sync.Once … }

func (t *T) init() { … }

func (t *T) method() {

t.once.Do(t.init) // t.init of type func(); t curried

  • terminating statement rule
    • no more panic(“unreachable”)

49 of 140

Go 1.2

Dec 2013

50 of 140

Go 1.2

  • guaranteed crash on nil pointer dereferences in all cases
  • three-index slices

slice := array[off:len:cap]

51 of 140

Go 1.3

Jun 2016

52 of 140

Go 1.3

  • no language changes

53 of 140

Go 1.4

Dec 2014

54 of 140

Go 1.4

  • for range x { … }
  • spec clarification & compiler fix: no double dereference on:�var x **T = nil�x.M()

55 of 140

Go 1.5

Aug 2015

56 of 140

Go 1.5

  • Map literal type elision:

m := map[Point]string{

{1, 2}: "Foo",

{3, 4}: "Bar",

}

57 of 140

Go 1.6

Feb 2016

58 of 140

Go 1.6

  • no language changes

59 of 140

Thank you!

Questions?

60 of 140

61 of 140

62 of 140

63 of 140

[ Excitement, pre-Go1 ]

weekly.*, r56, r57, etc

[ Go 1.x era ]

64 of 140

https://twitter.com/jrstahl/status/591656618275819520

65 of 140

Boring?

If you’re a language nerd.

66 of 140

Boring is exciting!

If you like stability.

67 of 140

Stable foundation

build stuff on top

68 of 140

“Go”

69 of 140

Language

Standard Library

Runtime

Tools

Ecosystem

70 of 140

Language

Basically frozen.

golang.org/ref/spec

71 of 140

Standard Library

Increasingly frozen.

External packages preferred.

72 of 140

Runtime

Garbage Collector,

maps, channels,

goroutine scheduler

Active development.

73 of 140

Tools

cmd/compile, gccgo, godoc, go doc, go vet, gofmt,

goimports, guru, gorename, …

Active development.

74 of 140

Ecosystem

External packages, compilers, tools.

Exploding.

75 of 140

Excitement elsewhere

excitement higher in the stack,

and in non-language areas of the foundation

76 of 140

Excitement besides

the language...

77 of 140

Go 1

Mar 2012

78 of 140

golang.org/doc/go1compat

79 of 140

Go 1 compatibility promise

  • your old March 2012 programs still work
  • we can add stuff
  • we can NOT change the language or standard library

80 of 140

Go 1: the beginning of tooling

  • cmd/go
  • go get
  • go install
  • go build
  • go test
  • etc

81 of 140

Go 1.1

May 2013

82 of 140

Go 1.1

  • int is 64-bit on 64-bit systems; address large heaps
  • race detector
  • +build constraints
  • more platforms (more OS/arch)
  • faster
  • stdlib growth, improvements

83 of 140

Go 1.2

Dec 2013

84 of 140

Go 1.2

  • performance
  • test coverage
  • goroutine preemption

85 of 140

Go 1.3

Jun 2016

86 of 140

Go 1.3

  • more platforms
  • contiguous stacks (mostly)
  • precise GC (mostly)
  • start of linker rewrite, speed
  • performance improvements
  • GC latency

87 of 140

Go 1.4

Dec 2014

88 of 140

Go 1.4

  • more platforms
  • much of runtime translated/ported from C to Go
  • fully precise GC
  • always contiguous stacks
  • stack sizes now 2KB instead of 8KB (previously 4KB)
  • write barrier for pointer assignments

89 of 140

Go 1.5

Aug 2015

90 of 140

Go 1.5

  • all C is gone
  • the compiler, linker, assembler, and runtime now all in Go
  • entirely new GC (Garbage Collector)
    • concurrent, much lower pause times
    • goal: 10ms worst case pause
  • automatic GOMAXPROCS
  • internal packages
  • vendor support in cmd/go
  • go doc (separate from godoc)

91 of 140

Go 1.6

Feb 2016

92 of 140

Go 1.6

  • no language changes

but….

93 of 140

Go 1.6: More Platforms

Current OS support:

  • Windows, OSX (darwin), Android, iOS, NaCl, DragonflyBSD, FreeBSD, Linux, NetBSD, OpenBSD, Plan 9, Solaris/Illumos

Current and new architecture support:

  • Intel (386 and amd64), arm (ARMv5, v6, v7), arm64, 64 bit PowerPC (big and little endian), 64 bit MIPS (big and little endian)

94 of 140

Go 1.6: Garbage Collector

Refined.

95 of 140

96 of 140

97 of 140

Go 1.6: cgo memory sharing

Defined.

98 of 140

Go 1.6: automatic HTTP/2

client & server

99 of 140

image by @igrigorik

100 of 140

http.Get, Client.Post, Do, etc.

no changes

101 of 140

http.ListenAndServeTLS

no changes

102 of 140

Use TLS!

LetsEncrypt, ACME, Caddy = Free!

103 of 140

Go 1.6: template package

now

with

less auto-generated

whitespace

104 of 140

Go 1.6: template package

{{now -}}

{{with -}}

{{- less}} {{- auto-generated -}}

{{- whitespace}}

105 of 140

Go 1.6: template package

now with less auto-generated whitespace

106 of 140

Go 1.6: template package

and {{block}}

107 of 140

Go 1.6: faster

crypto, compression, sorting, etc.

more escape analysis

108 of 140

Go 1.6: map misuse detection

best-effort, always-on check of concurrent R+W, W+W

109 of 140

Go 1.6: Windows timer resolution

better battery life on Windows

110 of 140

Go 1.6: stdlib changes

~50 things mentioned in release notes

111 of 140

So now what?

112 of 140

Go 1.6.1

the “whoops!” release

113 of 140

Go 1.7

Hacking time! Started this morning!

Due Aug 2016

114 of 140

Go 1.7: SSA

faster, smaller generated code

115 of 140

$ find . -name '*.rules'

./src/cmd/compile/internal/ssa/gen/AMD64.rules

./src/cmd/compile/internal/ssa/gen/generic.rules

116 of 140

// constant folding

(Neg8 (Const8 [c])) -> (Const8 [-c])

(Neg16 (Const16 [c])) -> (Const16 [-c])

(Neg32 (Const32 [c])) -> (Const32 [-c])

(Neg64 (Const64 [c])) -> (Const64 [-c])

// canonicalize: swap arguments for commutative operations when one argument is a constant.

(Eq64 x (Const64 <t> [c])) && x.Op != OpConst64 -> (Eq64 (Const64 <t> [c]) x)

(Eq32 x (Const32 <t> [c])) && x.Op != OpConst32 -> (Eq32 (Const32 <t> [c]) x)

(Eq16 x (Const16 <t> [c])) && x.Op != OpConst16 -> (Eq16 (Const16 <t> [c]) x)

(Eq8 x (Const8 <t> [c])) && x.Op != OpConst8 -> (Eq8 (Const8 <t> [c]) x)

// simplifications

(Or64 x x) -> x

(Or64 (Const64 [0]) x) -> x

(Or8 (Const8 [0]) x) -> x

(Or64 (Const64 [-1]) _) -> (Const64 [-1])

(Or8 (Const8 [-1]) _) -> (Const8 [-1])

(And64 x x) -> x

(And64 (Const64 [-1]) x) -> x

(And64 (Const64 [0]) _) -> (Const64 [0])

(Xor64 x x) -> (Const64 [0])

117 of 140

// Lowering arithmetic

(Add64 x y) -> (ADDQ x y)

(AddPtr x y) -> (ADDQ x y)

(Add32 x y) -> (ADDL x y)

(Add16 x y) -> (ADDW x y)

(Add8 x y) -> (ADDB x y)

(Add64F x y) -> (ADDSD x y)

(Lsh8x64 <t> x y) -> (ANDB (SHLB <t> x y) (SBBLcarrymask <t> (CMPQconst y [8])))

(Lsh8x32 <t> x y) -> (ANDB (SHLB <t> x y) (SBBLcarrymask <t> (CMPLconst y [8])))

(Lsh8x16 <t> x y) -> (ANDB (SHLB <t> x y) (SBBLcarrymask <t> (CMPWconst y [8])))

(Lsh8x8 <t> x y) -> (ANDB (SHLB <t> x y) (SBBLcarrymask <t> (CMPBconst y [8])))

// fold LEAQs together

(LEAQ [off1] {sym1} (LEAQ [off2] {sym2} x)) && canMergeSym(sym1, sym2) ->

(LEAQ [addOff(off1,off2)] {mergeSym(sym1,sym2)} x)

// LEAQ into LEAQ1

(LEAQ1 [off1] {sym1} (LEAQ [off2] {sym2} x) y) && canMergeSym(sym1, sym2) && x.Op != OpSB ->

(LEAQ1 [addOff(off1,off2)] {mergeSym(sym1,sym2)} x y)

(LEAQ1 [off1] {sym1} x (LEAQ [off2] {sym2} y)) && canMergeSym(sym1, sym2) && y.Op != OpSB ->

(LEAQ1 [addOff(off1,off2)] {mergeSym(sym1,sym2)} x y)

118 of 140

Rules easy to add…

… sent this morning

119 of 140

Go 1.7: vendor always on

no more GO15VENDOREXPERIMENT

120 of 140

Go 1.7: new *.a files

smaller, faster

121 of 140

122 of 140

Go 1.7: zip-based *.a files

4x smaller $GOPATH/pkg/*

123 of 140

Go 1.7: binary export data

124 of 140

125 of 140

Go 1.7: compression optimizations

faster zip/flate

126 of 140

Go 1.7: smaller binaries

already in progress

127 of 140

… sent this morning

128 of 140

Go 1.7: faster builds?

Go 1.5 was unfortunate

Go 1.6’s lack of fix was a little embarrassing

129 of 140

Go 1.7: new GC tuning, experiments

goroutine-local young gen, maybe?

130 of 140

Go 1.7: http2 PUSH_PROMISE?

and performance optimizations

(profile + tune frame/TLS record sizes)

131 of 140

Go 1.7: IDNA?

http.Get(“https://ಹಲೋ.in”)

net.Dial(“tcp”, “ಹಲೋ.in:443”)

132 of 140

Go 1.7: more architectures

add SPARC64, S390[x]

optimize PPC64 & ARM64 & MIPS64

maybe add RISC-V?

133 of 140

Go 1.7: little stdlib things

many open Go1.7 feature requests

134 of 140

Go 1.7: SSA

did I mention SSA?

135 of 140

Go 1.8

Feb 2017

136 of 140

Go 1.8: ???

More compiler polish (more SSA),

Better GC

etc.

137 of 140

Go 1.9: ???

you get the picture

138 of 140

Go 1.10: ???

you get the picture

139 of 140

Go 1.x

Solid foundation to build upon

Excitement can be found upstairs

140 of 140

Thank you!

Questions?