Go

Why use it for building web application?

@sebasporto

Comparing it to languages I use and love


Ruby

JavaScript

To start with


It is fast

Bubble sort benchmark

# ruby
bubble.call([2, 10, 1, 9, 5, 6, 8, 3, 7, 4])

// JS
bubble([2, 10, 1, 9, 5, 6, 8, 3, 7, 4]);

// Go
arr := []int{2, 10, 1, 9, 5, 6, 8, 3, 7, 4}
bubble(arr)

Code here

It is fast!




190x faster than Ruby

Concurrency as core feature

Concurrency - Parallel requests


Concurrency - Parallel requests

Ruby


  • Mutex and Threads :(
  • EventMachine :(

Concurrency - Parallel requests

Node.js


var defX = Q.defer();
var defY = Q.defer();

var oneAndTwo = Q
 .all([defX.promise, defY.promise])
 .then(processConcat);
 
requestValue('/x', defX);
requestValue('/y', defY);

Concurrency - Parallel requests

Go


var cx chan string = make(chan string)
var cy chan string = make(chan string)

go requestValue("/x", cx)
go requestValue("/y", cy)

x := <-cx
y := <-cy

processConcat(x, y)

Efficient memory usage


# Run benchmark
ab -n 10000 -c 100 http://127.0.0.1:8100/

Node.js

FATAL ERROR: (...) process out of memory

Go

Time taken for tests:   20.689 seconds
Complete requests:      10000

# No problems

Rich standard library


Static typing (+ IMO)


Compiled

But ultra fast

Single binary

A lot more



It is great alternative

Try it!

Thanks

@sebasporto