Slide 1

Slide 1 text

GO @NATHANY Photo Credit: Nathan Youngman

Slide 2

Slide 2 text

KEN THOMPSON Unix team at Bell Labs, see “Coders at Work”.! Created grep in an evening! Designed UTF-8 on a diner placemat Image courtesy of the Computer History Museum

Slide 3

Slide 3 text

ROBERT GRIESEMER Strongtalk VM! Java HotSpot VM! Code generation for V8 Creative Commons Attribute-Share Alike

Slide 4

Slide 4 text

ROB PIKE First window system for Unix at Bell Labs! Co-author of 2 books with Brian Kernighan! Newsqueak, Limbo: Implementations of Tony Hoare’s CSP “Concurrency Is Not Parallelism” - Waza 2012

Slide 5

Slide 5 text

WHAT IS GO? Imperative! Object-oriented! Concurrent

Slide 6

Slide 6 text

HELLO GO package main
 
 import (
 "fmt"
 "os"
 )
 
 func main() {
 who := "World"
 
 if len(os.Args) > 1 {
 who = os.Args[1]
 }
 
 fmt.Println("Hello", who)
 }
 $ go build hello.go $ ./hello "GDG Edmonton" Hello GDG Edmonton $ go run hello.go "YEG" Hello YEG

Slide 7

Slide 7 text

COMPILED & DYNAMIC Compilation Very strict Very fast Typing Static typing Type inference Literals Low-level primitives! uint, float64 Hash maps! Variable length arrays Memory Pointers Garbage collected Interfaces Statically checked Implicitly satisfied

Slide 8

Slide 8 text

HELLO OOP package main
 
 import "fmt"
 
 type Population int
 
 func (population Population) Greet() {
 fmt.Printf("Hello all the %d people!\n", population)
 }
 
 func main() {
 world := Population(6973738433)
 world.Greet()
 }


Slide 9

Slide 9 text

STRUCTURES package main
 
 import "fmt"
 
 type Person struct {
 FirstName, LastName string
 }
 
 func (person Person) Greet() {
 fmt.Println("Hello", person.FirstName, person.LastName)
 }
 
 func main() {
 dan := Person{"Daniel", "Huckstep"}
 dan.Greet()
 }


Slide 10

Slide 10 text

INTERFACES // ...
 type Greeter interface {
 Greet()
 }
 
 func GreetEveryone(everyone ...Greeter) {
 for _, someone := range everyone {
 someone.Greet()
 }
 }
 
 func main() {
 world := Population(6973738433)
 dan := Person{"Daniel", "Huckstep"}
 GreetEveryone(world, dan)
 }

Slide 11

Slide 11 text

LANGUAGES PHP! ColdFusion! Java! JavaScript! Ruby AMD/Intel x86 dual core Python 1991 C# 2000 1995 Clojure Go 2007 2009

Slide 12

Slide 12 text

C10K Linux! pthreads 8MB! (default) Windows threads 1MB Ruby ! fibers 4K Typical stack Stack Heap SP Program Stack 2 Segmented stacks Goroutines 8K+ Memory layout SP

Slide 13

Slide 13 text

GOROUTINES // ...
 func Postcard(from string) {
 fmt.Println("Hello from", from)
 }
 
 func main() {
 Postcard("Main")
 
 go Postcard("A goroutine")
 
 go func() {
 fmt.Println("A closure")
 }()
 
 time.Sleep(1 * time.Second)
 }

Slide 14

Slide 14 text

CONCURRENCY func main() {
 channel := make(chan string)
 go fish(channel)
 
 for fish := range channel {
 fmt.Println(fish)
 }
 }
 
 func fish(channel chan<- string) {
 fishes := []string{"Trout", "Salmon", "Perch", "Bass"}
 for _, fish := range fishes {
 channel <- fish
 }
 close(channel)
 }

Slide 15

Slide 15 text

CONCURRENT COMPOSITION func play(channel chan<- string) {
 channel <- "Plants vs. Zombies"
 channel <- "Fruit Ninja"
 }
 
 func main() {
 river, appstore := make(chan string), make(chan string)
 go fish(river); go play(appstore)
 
 select {
 case fish := <-river:
 fmt.Println("caught a", fish)
 case game := <-appstore:
 fmt.Println("passed", game)
 }
 }

Slide 16

Slide 16 text

WHAT ELSE? gofmt! exported identifiers! the standard library! import "github.com/lib/pq"! arbitrary precision constants! iota for enumerations! slices vs. arrays! pointers vs. unsafe! buffered channels! first-class channels! interior pointers! init()! zero-initialization! constructors! embedding (delegation)! interface{}! type assertions/switches! tagging and reflection! defer! panic/recover! multiple return values

Slide 17

Slide 17 text

“Go will be the server language of the future.” Tobias Lütke (founder, Shopify) Real-Time Web Concurrency Cloud Startup time Resilience Deploy a static binary Web Google Scale Dependency management Developer Happiness Clarity and simplicity

Slide 18

Slide 18 text

“Go has been described by several engineers here as a WYSIWYG language. That is, the code does exactly what it says on the page.” Peter Bourgon (SoundCloud)! golang.org The Go Programming Language ! godoc.org GoDoc ! gobyexample.com Go by Example (literate programming) ! nathany.com/good Go Object Oriented Design ! vimeo.com/49718712 Concurrency Is Not Parallelism ! bit.ly/goyeg Go Edmonton on Google+