intro to go (bangkok launchpad 2014)

Post on 13-Jan-2015

235 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Introduction to GO programming language done in Bangkok at Launchpad

TRANSCRIPT

Intro to GO

Bangkok GO Meetup 2014

Still learning thai

English>?

My Level of thai

● Who a hip language, Ruby / Javascript

● Who uses Java / C#

● Has anyone played with GO?

Survey the Audience

● Instant Messenger Server in GO

● Why we chose go

● Basics about go

● How to get started with GO

Whats this talk about

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

Who am I ?

● Instant Messaging Server / Client

● Backend 100% GO

● 300k user base of financial traders!

● 20 Megabits of sustained traffic

What we’re we using

Why GO?

● Dying

● Hard to hire people

● Nothing new happening

● Not cool

C++

● Slow to code

● Very verbose

● Need a much larger team

Java

● Hate windows on a server

C#

● Lightweight concurrency

● Fast development cycle

● Hip with the kids

GO

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

About GO

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

For javascript/ruby devs

valueToCloseOver := "My name is HAL."

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

Lambdas

● Lightweight threads

● Easy concurrency

● Like Erlang, communicate instead of sharing memory

Go Routines

● Container for messages between go routines

● Concorrent safe

Channels

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

● Interfaces over inheritance

● Duck typing

● Composition

No inheritance

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

● Windows support

● Small number of libraries

● Community still small but growing

Things not so good

● http://play.golang.org/

● http://golang.org/doc/

How to get started

Q/A

Btw We’re Hiring !

Thanks!

top related