Why Go Lang?
@sathishvj
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
Tech Migrations
3
Why are products/projects written in Go?
4
● https://blog.iron.io/how-we-went-from-30-servers-to-2-go/
5
● https://rcoh.me/posts/why-you-can-have-a-million-go-routines-but-only-1000-jav
a-threads/
6
● https://medium.com/koinex-crunch/pushman-the-koinex-standard-for-realtime-e
xperience-4122d2715c92
7
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
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
● 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
Fast in Build
11
Fast in Execution
12
Interest (via google trends)
13
Can Utilize Multiple CPUs and Cores
14
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
Go: The lean, mean, fit machine
16
OSOSOSOSOSOS
GoGoGoGoGo
App App App
Compiled Language: Direct Machine Code
● No JVM/.Net/Python/Node environments
● No local builds in each deploy location
17
Cross Compiling
● Much better solution than “platform independence” of Java/C#/Python
18
Much Simpler but More Effective Parallelism
● How many of you have regularly coded multithreaded programs?
19
Go Tooling
● Unit Testing
● Benchmarking
● Coverage
● Profiling - CPU, memory, blocking, latency
● Call graphs, flame charts
20
Governance
● Very strong backward compatibility guarantee
● Changes go through strong vetting process
● Keeps original design goals of speed and ease
21
Developer Love - Wanted and Loved
22
https://insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wanted
Hackerrank Survey 2018
23
https://research.hackerrank.com/developer-skills/2018
Very Strongly Typed - Less implicit conversions
● Less errors in production
● Less random errors
24
Smaller, Simpler Language -> Compound Programs
25ref: https://github.com/leighmcculloch/keywords
Less is exponentially more. - Rob Pike
26
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
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
Thank you!
Questions?
You can find me at:
Twitter: @sathishvj
LinkedIn: Sathish VJ
29

Why Go Lang?

  • 1.
  • 2.
    Some products writtenin 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
  • 3.
  • 4.
    Why are products/projectswritten in Go? 4
  • 5.
  • 6.
  • 7.
  • 8.
    dl.google.com now servedby 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 ● RobertGriesemer ● 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’tscale 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
  • 11.
  • 12.
  • 13.
  • 14.
    Can Utilize MultipleCPUs and Cores 14
  • 15.
    Statically Compiled ● Everythingrequired 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: DirectMachine Code ● No JVM/.Net/Python/Node environments ● No local builds in each deploy location 17
  • 18.
    Cross Compiling ● Muchbetter solution than “platform independence” of Java/C#/Python 18
  • 19.
    Much Simpler butMore Effective Parallelism ● How many of you have regularly coded multithreaded programs? 19
  • 20.
    Go Tooling ● UnitTesting ● Benchmarking ● Coverage ● Profiling - CPU, memory, blocking, latency ● Call graphs, flame charts 20
  • 21.
    Governance ● Very strongbackward 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
  • 23.
  • 24.
    Very Strongly Typed- Less implicit conversions ● Less errors in production ● Less random errors 24
  • 25.
    Smaller, Simpler Language-> Compound Programs 25ref: https://github.com/leighmcculloch/keywords
  • 26.
    Less is exponentiallymore. - Rob Pike 26
  • 27.
    Other Advantages ● Allowsyour 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 thatpeople 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
  • 29.
    Thank you! Questions? You canfind me at: Twitter: @sathishvj LinkedIn: Sathish VJ 29