7. Implementation of gh
• Implemented in Go
• Fast (40% faster than Hub)
• A single, statically linked binary with no
dependencies (noVM needed!)
• Unix, e.g., gh pull -b integration -h
new_feature
8. What’s Go?
• Imperative
• Object-oriented like
• Concurrent
• Compile to machine code
• Created at 2009, v1.1.1
9. Ken Thompson
• Founding father of Unix, see
“Coders at work”
• Bring in regular expression
to computing
• Created grep in an evening
• Designed UTF-8 on a diner
placemat
10. Robert Griesemer
• Native code generation for
V8
• Java HotSpotVM
• StrongtalkVM (inspires the
DartVM)
11. Rob Pike
• First window system for
Unix at Bell Labs
• Plan 9
• Co-Authors of “The Unix
Programming Environment”
& “The Practice of
Programming” with Brian
Kernighan
• Newsqueak, Limbo:
implementations of Tony
Hoare’s CSP
12. Why Go?
• Why Learn Go? An interview with Rob
Pike: http://www.youtube.com/watch?
v=FTl0tl9BGdc
14. More about Go
• Compilation is very fast, gh has 1581 LOC,
the build time is 0.77s
• Static typing & type inference
• Low level primitives uint, float64
• Garbage collected
• Pointers without pointer arithmetic
16. The C10K Problem
• The problem of optimizing socket server
software to handle a large number of
clients at the same time
• C10k = concurrent ten thousand
connections
• Linux pthreads (8MB),Windows (1MB),
Coroutines (4k, e.g., Ruby Fibers)
17. Goroutines
• Coroutines in Go, 4K, light weight threads
• Segmented stacks (a double linked lists)
• No stack-overflow
• Automatically scale to multiple-cores
• In the future, scale to multiple machines
20. Learning from gh
• Right tool for the job - building a Unix tool
• Go’s compiler is freaking fast!
• Clarity and simplicity, less is more
• Go fmt
• Fast startup time, low memory usage
• Deploy a static library (making deployment so
much simpler!)
• Goroutines & channels (higher level APIs in net/
http)
21. References
• gh: https://github.com/jingweno/gh
• Code examples: https://gist.github.com/
jingweno/c00e973ade6d66b827fd
• Go at Google: http://www.infoq.com/
presentations/Go-Google
• Concurrency is not Parallelism: http://
vimeo.com/49718712
• Real world Go: https://gist.github.com/
ungerik/3731476