Intro to GO (Bangkok Launchpad 2014)

28
Intro to GO Bangkok GO Meetup 2014

description

Introduction to GO programming language done in Bangkok at Launchpad

Transcript of Intro to GO (Bangkok Launchpad 2014)

Page 1: Intro to GO (Bangkok Launchpad 2014)

Intro to GO

Bangkok GO Meetup 2014

Page 2: Intro to GO (Bangkok Launchpad 2014)

Still learning thai

English>?

Page 3: Intro to GO (Bangkok Launchpad 2014)

My Level of thai

Page 4: Intro to GO (Bangkok Launchpad 2014)

● Who a hip language, Ruby / Javascript

● Who uses Java / C#

● Has anyone played with GO?

Survey the Audience

Page 5: Intro to GO (Bangkok Launchpad 2014)

● Instant Messenger Server in GO

● Why we chose go

● Basics about go

● How to get started with GO

Whats this talk about

Page 6: Intro to GO (Bangkok Launchpad 2014)
Page 7: Intro to GO (Bangkok Launchpad 2014)

Small consulting firm Hyperworks*Built Bloomberg.com*Real time ad servers*Ecommerce sites (gucci,reebok etc)*Thomson Reuters Messenger Client/Server

Who am I ?

Page 8: Intro to GO (Bangkok Launchpad 2014)

● Instant Messaging Server / Client

● Backend 100% GO

● 300k user base of financial traders!

● 20 Megabits of sustained traffic

What we’re we using

Page 9: Intro to GO (Bangkok Launchpad 2014)

Why GO?

Page 10: Intro to GO (Bangkok Launchpad 2014)
Page 11: Intro to GO (Bangkok Launchpad 2014)

● Dying

● Hard to hire people

● Nothing new happening

● Not cool

C++

Page 12: Intro to GO (Bangkok Launchpad 2014)

● Slow to code

● Very verbose

● Need a much larger team

Java

Page 13: Intro to GO (Bangkok Launchpad 2014)

● Hate windows on a server

C#

Page 14: Intro to GO (Bangkok Launchpad 2014)

● Lightweight concurrency

● Fast development cycle

● Hip with the kids

GO

Page 15: Intro to GO (Bangkok Launchpad 2014)

● Google’s programming language● Garbage collected● Author is Rob Pike (Inventor of unix)● Fast Compilations● Fast Runtime● Easy to learn

About GO

Page 16: Intro to GO (Bangkok Launchpad 2014)

Hello World (Aka a webserver)import (

"fmt""http"

)func handler(c *http.Conn, r *http.Request) {

fmt.Fprintf(c, "Hello, %s.\n", r.URL.Path[1:])}func main() {

http.ListenAndServe(":8080", http.HandlerFunc(handler))}

Go is like C/C#/Java

Page 17: Intro to GO (Bangkok Launchpad 2014)

For javascript/ruby devs

valueToCloseOver := "My name is HAL."

anon := func(s string) string { return "Hiya, " + name + ". " + valueToCloseOver } anotherFunction(anon)

Lambdas

Page 18: Intro to GO (Bangkok Launchpad 2014)
Page 19: Intro to GO (Bangkok Launchpad 2014)

● Lightweight threads

● Easy concurrency

● Like Erlang, communicate instead of sharing memory

Go Routines

Page 20: Intro to GO (Bangkok Launchpad 2014)

● Container for messages between go routines

● Concorrent safe

Channels

Page 21: Intro to GO (Bangkok Launchpad 2014)

c := make(chan int) // Allocate a channel.// Start the sort in a goroutine; when it completes, signal on the channel.

go func() { list.Sort() c <- 1 // Send a signal; value does not matter.}()

doSomethingForAWhile()<-c // Wait for sort to finish; discard sent value.

Code samples

Page 22: Intro to GO (Bangkok Launchpad 2014)

● Interfaces over inheritance

● Duck typing

● Composition

No inheritance

Page 23: Intro to GO (Bangkok Launchpad 2014)

type Stringer interface { String() string}

var value interface{} // Value provided by caller.switch str := value.(type) {case string: return strcase Stringer: return str.String()}

Example interface code

Page 24: Intro to GO (Bangkok Launchpad 2014)
Page 25: Intro to GO (Bangkok Launchpad 2014)

● Windows support

● Small number of libraries

● Community still small but growing

Things not so good

Page 26: Intro to GO (Bangkok Launchpad 2014)

● http://play.golang.org/

● http://golang.org/doc/

How to get started

Page 27: Intro to GO (Bangkok Launchpad 2014)

Q/A

Page 28: Intro to GO (Bangkok Launchpad 2014)

Btw We’re Hiring !

Thanks!