This talk covers a very basic introduction to the Go programming language. It is designed for people who already have a cursory (or better) understanding of programming principles, but may not be familiar with the syntax, etc.
"MODERN" Pick one: - efficient compilation - efficient execution - ease of development PROBLEMS REQUIREMENTS Compile FAST Execute FAST Concurrency Support for dependencies Built-in GC Good enough for Google Type safety Modern JavaScript Objective-C/Swift
Scala "MODERN" Pick one: - efficient compilation - efficient execution - ease of development PROBLEMS REQUIREMENTS Compile FAST Execute FAST Concurrency Support for dependencies Go! Built-in GC Good enough for Google Type safety Modern JavaScript Objective-C/Swift
Scala "MODERN" Pick one: - efficient compilation - efficient execution - ease of development PROBLEMS REQUIREMENTS Compile FAST Execute FAST Concurrency Support for dependencies 2015 today Built-in GC Good enough for Google Type safety Modern JavaScript Objective-C/Swift
max; i++ { if i %3 == 0 && i %5 == 0 { fmt.Println("Fizzbuzz") } else if i%3 == 0 { fmt.Println("Fizz") } else if i%5 == 0 { fmt.Println("Buzz") } else { fmt.Println(i) } } } fizzbuzz.go def fizzbuzz(max) 1.upto(max) do |i| if i % 5 == 0 and i % 3 == 0 puts "FizzBuzz" elsif i % 3== 0 puts "Fizz" elsif i % 5 == 0 puts "Buzz" else puts i end end end fizzbuzz.rb
max; i++ { if i %3 == 0 && i %5 == 0 { fmt.Println("Fizzbuzz") continue } if i%3 == 0 { fmt.Println("Fizz") continue } if i%5 == 0 { fmt.Println("Buzz") continue } fmt.Println(i) } } fizzbuzz.go def fizzbuzz(max) 1.upto(max) do |i| if i % 5 == 0 and i % 3 == 0 puts "FizzBuzz" next end if i % 3== 0 puts "Fizz" next end if i % 5 == 0 puts "Buzz" next end puts i end end fizzbuzz.rb
return max } else { return fib(max-1) + fib(max-2) } } fib.go def fib(max) if max < 2 return max else return fib(max-1) + fib(max-2) end end fib.rb fib(40) fib(40)
return max } else { return fib(max-1) + fib(max-2) } } fib.go def fib(max) if max < 2 return max else return fib(max-1) + fib(max-2) end end fib.rb fib(40) 1.02s user 0.01s system 99% cpu 1.027 total fib(40)
return max } else { return fib(max-1) + fib(max-2) } } fib.go def fib(max) if max < 2 return max else return fib(max-1) + fib(max-2) end end fib.rb fib(40) 1.02s user 0.01s system 99% cpu 1.027 total fib(40) 17.37s user 0.04s system 99% cpu 17.467 total
for c := 0; c < max; c++ { i, j = i+j, i } return i } fib.go fib(1000) 0.00s user 0.00s system 72% cpu 0.004 total 43466557686937456435688527675040625802564660517371780402481729089536555417 94905189040387984007925516929592259308032263477520968962323987332247116164 2996440906533187938298969649928516003704476137795166849228875
func() { for i, j := 0, 1; ; i, j = i+j, i { c <- i } }() return c } func main() { fib := fibGenerator() for i := 0; i < 25; i++ { fmt.Println( ? ) } } fib.go
func() { for i, j := 0, 1; ; i, j = i+j, i { c <- i } }() return c } func main() { fib := fibGenerator() for i := 0; i < 25; i++ { fmt.Println(<-fib) } } fib.go
func() { for i, j := 0, 1; ; i, j = i+j, i { c <- i } }() return c } func main() { fib := fibGenerator() for i := 0; i < 25; i++ { fmt.Println(<-fib) } } fib.go
func() { for i, j := 0, 1; ; i, j = i+j, i { c <- i } }() return c } func main() { fib1 := fibGenerator() fib2 := fibGenerator() for i := 0; i < 5; i++ { fmt.Println(<-fib1) } for i := 0; i < 5; i++ { fmt.Println(<-fib2) } } fib.go
func() { for i, j := 0, 1; ; i, j = i+j, i { c <- i } }() return c } func main() { fib1 := fibGenerator() fib2 := fibGenerator() for i := 0; i < 5; i++ { fmt.Println(<-fib1) } for i := 0; i < 5; i++ { fmt.Println(<-fib2) } } fib.go
the channel buffer. Buffer int // Ch is the internal channel where numbers are written. Ch chan int } func PublicFunc() {} func privateFunc() {} structs.go
the channel buffer. buffer int // ch is the internal channel where numbers are written. ch chan int } func NewFib(b int) (*Fib, error) { f := new(fib) f.buffer = b f.ch = make(chan int, b) go func(f *Fib) { for i, j := 0, 1; ; i, j = i+j, i { f.ch <- i } }(f) return f, nil } structs.go
the channel buffer. buffer int // ch is the internal channel where numbers are written. ch chan int } // Next gets the next number in the fib sequence. func (f *fib) Next() int { } structs.go
the channel buffer. buffer int // ch is the internal channel where numbers are written. ch chan int } // Next gets the next number in the fib sequence. func (f *fib) Next() int { return <-f.ch } structs.go