# Go (Language)

## Summary


Go is an open source, compiled, concurrent, garbage-collected, statically typed language developed at Google. Google created it to solve its own problems in relation to multicore processors, networked systems and large codebases. 

While languages such as C and C++ are fast, they are hard to master and development takes longer. While Python is easier to work with, it compromises on runtime efficiency. Go was designed to be efficient, scalable and productive.

## Discussion

### Why was Go invented when there were already many popular languages?

Go was invented (in 2007) at a time when multicore CPU architectures were common, largely because Moore's Law was failing to deliver. With multiple cores, code can run in parallel on all available cores; but there was no programming language that simplified the development of multithreaded applications. The responsibility of managing different threads safely and efficiently fell on developers. Thread-locking, race conditions and deadlocks are usual challenges. Go was designed with concurrent programming in mind. 

Golang FAQ states that in the days before Go, 

> One had to choose either efficient compilation, efficient execution, or ease of programming; all three were not available in the same mainstream language.

Go balances these different expectations of a programming language. Go was really designed to solve problems Google faced with large software systems. Hence, it was less about research into language design and more about software engineering to solve problems at hand. Some of the problems Google faced were slow builds, uncontrolled dependencies, poor code readability, challenges with automation tools and cross-language builds. 


### What are the main features of Go language?

Go's main features include concurrency, scalability, error checking, fast performance, garbage collection and cross platform. It's fast because it's a compiled language and not an interpreted one like JavaScript. Garbage collection pauses have been reduced to about 100 microseconds. Go's built-in error type enables developers to spot errors early. It's designed for the cloud and can run on various platforms. 

Because Go has types and methods, we can call it an object-oriented language. But there's no type inheritance. Instead, Go uses **interfaces**. 

Go achieves concurrency using **goroutines**, which are then mapped to operating system threads. If a thread is blocked, goroutines can be moved to another thread. Goroutines are therefore cheap, requiring nothing more than stack memory. Built-in **channels** are used to communicate between goroutines. 

Go is opinionated and focused on its design goals. Therefore, what it leaves out of the language are just as important. Go doesn't have generic types, exceptions and assertions. 

Other features mentioned elsewhere are `godoc` for documentation; `gofmt` for code formatting; `golint` for linting; built-in testing and profiling framework; race condition detection. 


### What sort of applications can benefit from using Go language?

If you're into systems programming with support for multithreading, Go is a suitable language. Go can be used for building any server-side app containing thousands of communicating threads. 

Due to its roots in Google, Go is suited for large distributed projects involving multiple teams. It's taken off in the cloud infrastructure space, platform automation, tooling apps and DevOps pipelines. Go's static binaries without external dependencies are easier to manage. Cross-platform CLI tools can be created. Because Go compiles to native code, performance-critical apps can benefit from it. As Go's Garbage Collection (GC) matures, it can suit embedded systems. 

While Go was originally for systems programming, it's been adopted for microservices. This is due to its "elegant concurrency model, simple binary deployments, low number of external dependencies, fast performance, and runtime efficiency." There's also an expectation (back in 2015) that Go will grow into a general-purpose programming language and be adopted for GUI apps, IoT apps, web/mobile apps, robotics frameworks, and more. It's suited for data science work. 

Alternatively, it's been said that Go is not suitable for GUI apps, kernels, drivers or embedded systems. 


### How's the adoption of Go language?

Back in 2014, it was reported that many open source projects have adopted Go: Docker, Kubernetes, Weave, Shipyard, etcd, Fleet, Deis, Flynn. Since Go is suited to distributed server apps, all of these apps are cloud related. Lime is an example of a desktop app for text editing. InfluxDB, a distributed time series database, is written in Go. Gogs (Go Git Service) helps you to run a Git service, like GitHub. Go is a suitable fit for Docker due to static compilation and ability to build for different architecture with less effort. 

Among the big names using Go are Uber, BBC, Novartis, Soundcloud and Basecamp. Uber has reported better throughput, latency and uptime. BBC uses it for backend, including crawlers and web scrapers. Soundcloud's build and deployment system is in Go. 

In 2016, Go was rated the most popular language in the TIOBE index. Multiple developer surveys in 2018 show interest and adoption of Go. In StackOverflow's survey, Go is in the top five most loved/wanted languages. Community contribution to Go is growing steadily. 

There's also a curated list of companies worldwide using Go.


### What are some criticisms of Go language?

Go doesn't support generics, which means that code written for one data type can't be reused for another. Interfaces are implicit. Sometimes it's hard to tell if a struct type implements an interface. Library support for Go from vendors is lacking. While Go is open source, key maintainers are seen to be non-receptive to suggestions from the community. Packages are not versioned in a centralized place. 

We can't define immutable data types. Complex data types are not available out of the box: hash, tree, set. Go doesn't support overloading. Compile-time checks are lacking. It's slow compared to C, C++ and Rust. It's been said that Rust succeeds in areas where Go fails. There's also a curated list of Go criticisms.

From Go's perspective, some missing features are actually by design, reflecting Go's simplicity. Generics come with a higher complexity. Without exceptions, developers are forced to do explicit error checking. Overloading makes problems harder to debug. Being minimal and opinionated means that everyone writes code the same way: there are no debates about using tabs versus spaces or for versus while. 


### For a beginner, what online resources can you recommend to learn Go programming?

Golang's official FAQ page is a good place to start. Other resources include the Go official documentation and the Go Wiki pages.

A curated list of Go frameworks and software is available on GitHub. There's also a curated list of 18 Go experts to follow. For latest news, the official Go blog and Golang Weekly newsletter are useful. For conferences, there's GopherCon and the European dotGo.

## Milestones

Sep  
2007

Three engineers at Google (Robert Griesemer, Rob Pike and Ken Thompson) invent **Go**. Their aim is to design a better language for Google's workflows. In particular, they notice lack of concurrency support in current languages and long build times. They want a small, compiled language with modern features. 

Nov  
2009

Go is made open source.  

Mar  
2012

A major release named **Go 1** is released. It's stated that language will be stable and compatible with future updates of Go 1. 

2014

World's first Go conference, **GopherCon**, is organized in Denver, USA. About 700 gophers (Go developers) attend the event. 

Jan  
2017

As a dependency management tool for Go packages, **dep** is released. Developers adopt this in preference to many community-led tools. Dep uses semantic versioning plus a configuration file that specifies dependencies. Version 0.1.0 of dep becomes available on GitHub in May 2017. 

Jul  
2017

At GopherCon 2017, Russ Cox presents initial ideas for **Go 2** with a goal "to fix the most significant ways Go fails to scale." He outlines the community process through which Go 2 will be defined. Early draft designs of Go 2 consider error values, error handling, and generic programming. As of November 2018, Go 2 is still under development. 

Aug  
2018

Version Go 1.11 is released. Two major versions are supported at any point in time. This means that versions 1.11 and 1.10 will be supported until version 1.12 appears.