
"Go is a programming language designed by Google to help solve Google's problems, and Google has big problems.”
Created inside Google by 3 Googlers
Rob Pike ; Ken Thompson ; Robert Griesemer
Started in Set 2007 ; Open-sourced in Nov 2009
Golang History - Origins
Born out of frustration with existing languages and environments for systems programming
One had to choose either efficient compilation, efficient execution, or ease of programming
all three were not available in the same mainstream language
Programmers who could were choosing ease over safety and efficiency by moving to dynamically typed languages such as Python and JavaScript rather than C++ or, to a lesser extent, Java.
Rob Spike: "Golang was built during C++ compilation time"
Golang History - Origins
Go is an attempt to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language
Golang History - Motivation
Golang History - Ancestors
Mostly C family (basic syntax)
Input from the Pascal/Modula/Oberon family (declarations, packages)
Inspired by Hoare's CSP, such as Newsqueak and Limbo (concurrency)
Java 8 language spec - 780 page PDF
Scala language spec - 191 page PDF
Go language spec - 51 page PDF
Golang - Concurrency is not Parallelism
Concurrency
Programming as the composition of independently executing processes.
Parallelism
Programming as the simultaneous execution of (possibly related) computations.
Golang - Concurrency is not Parallelism
Concurrency is about dealing with lots of things at once.
Parallelism is about doing lots of things at once.
Not the same, but related.
Concurrency is about structure
Parallelism is about execution
Concurrency provides a way to structure a solution to solve a problem that may (but not necessarily) be parallelizable.




Single Process Execution
Concurrent Solution #1
Concurrent Solution #2
Golang - Concurrency
Parallelization of the previous concurrent solution
Golang - Concurrency

Golang - Concurrency
Concurrency is a way to structure a program by breaking it into pieces that can be executed independently
In concurrent development we need a way to coordinate the independent executions
Shared memory with explicit synchronization
mutex ; pthreads ; monitors ; locks ( C, Java, C# )
Transactional Memory
memory shared between threads in atomic transactions. thread may make accesses to shared mutable variables and have guaranteed isolation ( Concurrent Haskell ; Clojure )
Message Passing
Threads no longer share mutable variables, but communicate by explicitly sending messages ( Golang ; Erlang )
Golang - Concurrency coordination models
Golang - Features
Compiled
Statically linked
Garbage Collected
Object Oriented ( sort of )
Concurrency at language level
Is
Functions as first class citizens
Structs and Interfaces
---- Default Zero Values
All code is UTF-8
Functions can return multiple named value
Pointers ( * and & )
Concurrency ( goroutines, channels, select )
Have
Golang - Features
Don't Have
Exceptions
Method or operator overloading
Pointer arithmetic
Generics
Circular dependencies among packages
Type inheritance ( hierarchy )
Type inference
Golang - NO Features
It's an independently executing function, launched by a go statement.
It has its own call stack, which grows and shrinks as required.
It's very cheap. It's practical to have thousands, even hundreds of thousands of goroutines.
There might be only one thread in a program with thousands of goroutines.
Goroutines are multiplexed dynamically onto threads as needed to keep all the goroutines running.
A control structure unique to concurrency.
The reason channels and goroutines are built into the language.

GOPATH
Use Cases
Systems tasks
APIs
Who's using it?
Hello, Web
on top of net/http
on top of database/sql
How fast?
Web Apps
https://github.com/rif/lov3lyme
https://github.com/thraxil/reticulum/
http://stevenyue.com/2014/02/10/from-rubys-grape-to-martini-in-go-for-building-web-api-server/
Can mix with Rails ( auth ) https://github.com/mattetti/goRailsYourself
FINAL NOTES
Private / Public
Really good documentation
go build -> single binary