2. Some products written in Go
● Kubernetes - Container Scheduling and Management
● Docker, Rkt, containerd - containers
● Go - go is written in go
● Prometheus - monitoring system
● Istio - Connect, secure, control, and observe services.
● bolt, cockroach, dgraph, goleveldb, gorocksdb, influxdb, tidb, tiedot - databases
● Ethereum - blockchain platform
● Caddy - http web server (vs nginx)
● Loki - like prometheus but for logging
● Ngrok - Introspected tunnels to localhost
● Grpcurl - curl for grpc
● Gogs - self hosted git service
● dl.google.com - rewritten in go
2
8. dl.google.com now served by Go (26/10/2012)
Google uses Go for many internal projects, but for confidentiality reasons it's rare that we can point to a specific example. YouTube’s open source vitess
project (http://code.google.com/p/vitess/) is one high-profile success story, and now I'm happy to announce another.
The service that runs dl.google.com--the source for Chrome, Earth, Android SDK, and other large Google downloads--has been rewritten in Go. In fact, if
you’ve had Chrome installed during the past few months then you have almost certainly talked to this Go program. :-)
Why rewrite in Go? It all started back in April of this year, when I was running "apt-get update" at home and noticed that downloads from dl.google.com
were stalling for no apparent reason. I asked about this on our internal Google+ and was put in touch with the right people. It turned out that the existing
C++ dl.google.com service was no longer actively maintained (short of being kept alive) and that it relied on some assumptions about Google's internal
architecture which were no longer true.
The C++ version had grown thorny over the years (so many callbacks!), and it still used some of Google’s oldest C++ libraries, long since deprecated. It
also had a few HTTP details wrong and a fair bit of duplicated code, sometimes missing pieces in some copies which were present in others. Much work
was required to fix it (or rewrite it in modern C++), so we decided instead to rewrite it in Go.
The Go version is much less code, more readable, more testable, doesn’t have blocking problems, and fixes a number of HTTP correctness issues from
the old version. It also compiles quickly. We were prepared to take a hit in CPU and/or memory usage in exchange for readable code, but it turned out that
the CPU was the same and the memory usage actually dropped!
The Go version also uses interfaces to abstract out the file system, so migrating from local disk (as used in the Go version while transitioning from C++) to
networked file systems (like our Colossus) was trivial. For the same reason, it was easy to introduce a memory caching layer for the most popular
downloads.
All this is to say: apt-get against dl.google.com is fast again. I’m happy. :-) 8
9. Go Creators
● Robert Griesemer
● Rob Pike (Unix, Plan9 from Bell Labs, Limbo, sam, acme, UTF-8,...)
● Ken Thompson (Unix, Plan9 from Bell Labs, B, UTF-8,...)
9
10. ● Some don’t scale for modern hardware - Python, Node
● Some are too complex - C++
● Some don’t distribute well - Java, C#, Python, Node
● Parallel programming is very useful but very challenging - all programs
● Tooling is splintered - all languages
● Modern systems require a modern language
Origins of Go
10
15. Statically Compiled
● Everything required by the app is available in the executable.
● So what does it take to deploy?
● No dll hell
● No upgrade dependencies
● No VM
● No dependent libraries
● Super easy in containerization
15
16. Go: The lean, mean, fit machine
16
OSOSOSOSOSOS
GoGoGoGoGo
App App App
17. Compiled Language: Direct Machine Code
● No JVM/.Net/Python/Node environments
● No local builds in each deploy location
17
18. Cross Compiling
● Much better solution than “platform independence” of Java/C#/Python
18
19. Much Simpler but More Effective Parallelism
● How many of you have regularly coded multithreaded programs?
19
21. Governance
● Very strong backward compatibility guarantee
● Changes go through strong vetting process
● Keeps original design goals of speed and ease
21
22. Developer Love - Wanted and Loved
22
https://insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wanted
27. Other Advantages
● Allows your programming language to evolve better.
○ Does not start with a big-bang design.
● Consistent formatting everywhere with “go fmt”
● New very useful “defer” keyword.
● Better defaults - implicit break in case, no semi-colons
● Slices pre-allocate unlike arrays and increases efficiency by a large amount in
return for some space
27
28. What’s different that people have found useful elsewhere?
● No GC in C/C++ - memory management is your problem. No bounds checking. No
GC.
○ So greater speed at the cost of reliability and robustness.
● No Generics in Go - matter of much debate. Does generics reduce speed?
● No Exceptions in Go - has a C like error return and catching. Simpler,
straightforward. A little more boiler-plate but very clear error handling.
● Not OOP (technically) - but we can achieve all similar concepts.
● No Macros in Go - no preprocessing, but there is code generation capability
● No pointer arithmetic- makes programs safer
● No operator overloading
● No default arguments
● Strict braces even around single line blocks - stops inadvertent block additions
● No ternary operator
28