Start your journey with Go

What is Go?

Go is a statically typed, compiled programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Go is syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency. The language is often referred to as "Golang" because of its domain name,, but the proper name is Go. Go language is an effort to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language. It also aims to be modern, with support for networked and multicore computing.

Why Go?

  • Flexible- It is concise, simple and easy to read.

  • Quick Outcome- Its compilation time is very fast. There is a high possibility that its compilation speed will make you believe that you are working with an interpreted language like Ruby.

  • Library- It provides a rich standard library.

  • Garbage collection- It is a key feature of go. Go excels in giving a lot of control over memory allocation and has dramatically reduced latency in the most recent versions of the garbage collector.

  • It validates for the interface and type embedding. It is both strongly and statically typed. You can’t pass any type of data everywhere. You need to be explicit. The compiler knows the type of every variable. In Go, there are no implicit type conversions.

  • Go provides us with the unit testing features by itself i.e., a simple mechanism to write your unit test parallel with your code because of this you can understand your code coverage by your own tests. And that can be easily used in generating your code documentation as an example.

  • Go language is just like Java language as it supports platform independence.

  • Concurrency- It allows multiple processes running simultaneously and effectively. This is probably the biggest reason for using Go. I will discuss it in details.

Concurrency in Go.

As pointed out earlier, the concurrency in Go is probably the biggest advantage of it over other languages. Java and some other languages support concurrent programming too. So why Go? Languages like Java and Python, which supports multi-threading are a product of 90s single-threaded environment. Though multi-threading was included very early in their updates, the languages, to their core, were not meant for a multi-threaded environment. As a result, multi-threading in these languages comes with a cost. For example, creating a new thread in Java is not memory efficient. As every thread consumes approx 1MB of the memory heap size and eventually if you start spinning thousands of threads, they will put tremendous pressure on the heap and will cause shut down due to out of memory. Also, if you want to communicate between two or more threads, it’s very difficult. On the other hand, Go was released in 2009 when multi-core processors were already available. That’s why Go is built with keeping concurrency in mind. Go has goroutines instead of threads. They consume almost 2KB memory from the heap. So, you can spin millions of goroutines at any time.

Benefits of GoRoutines :

  • Goroutines uses more memory only when needed. This is done with the help of a segmented stack which is growable in nature.

  • Goroutines starts faster than a thread.

  • Goroutines come with built-in primitives to communicate safely between themselves.

  • Goroutines allow you to avoid having to resort to mutex locking when sharing data structures.

  • A single goroutine can run on multiple threads. Goroutines are multiplexed into a small number of OS threads.

Watch this video to understand more about the Go style of concurrency.

Where is Go used?

Some of the companies that are using Go in production:

  • Docker

  • Openshift

  • Kubernetes

  • Dropbox - Migrated some of their critical components from Python to Go.

  • Netflix - Two part of their server architecture.

  • Heroku

  • Medium

  • Lyft

  • Uber

As the programming community knows, the popular use of language can be determined by the number of questions being asked about it on StackOverflow.

Some links for more brain-food:

This post will be followed by a series of blog posts where we will deep dive into the language concepts and try to make our first Go App.



©2020 by Aman Sinha.