Golang, also known as “Go, ” is a compiled language, fast and high-performance language intended to be simple and is designed to be easy to read and understand. Go was created at Google by Rob Pike, Robert Griesemer, and Ken Thompson, and it first appeared in Nov 2009. The syntax of Golang is designed to be highly clean and accessible.
Go was invented in 2007 at such a time when multicore CPU architectures were common everywhere, and no programming language simplified the development of multi-threaded applications. The responsibility of managing different threads safely and efficiently was a huge responsibility on developers. Go is different from other languages; it is young yet so powerful. Goroutines revolutionized competitive programming on the other level.
It is tested and proved that applications that are written on Go are highly performant and scalable. Golang is a very efficient language, just like C/C++, handling parallelisms like Java, and has easy code readability like Python and pearl. Golang has indisputable architectural advantages over its predecessors.
Go is used by some of the big brands such as BBC, Uber, Novartis, Basecamp, and Soundcloud. Uber has reported better throughput, high performance, latency, and uptime. BBC, the house name in broadcasting the world news, uses it for backend, including crawlers and web scrapers. The build and deployment system of Soundcloud is in Go.
Why Go?
It is effortless to learn for programmers with C++ experience, and also converting legacy code to Go is pretty straightforward and fairly simple. Being a compiled, statically typed language, it’s much faster than interpreted options and also offers most of the performance benefits. Go as a language is more similar to C, however in addition to C features, Go offers memory safety, garbage collection, structural typing, and CSP-Style concurrency.
Go fits really well for general performance-oriented cloud software. The popular DevOps tools are written in Go, such as Docker, and even the open-source container orchestration system Kubernetes is built on go. Vitess, a Google built distributed database system and a MySQL backend built with Golang, has been in use by YouTube since 2011.
Golang ranked in the 5th position in the Stack Overflow Survey that was conducted in 2018. According to the Q2 GitHub report in 2018, Golang had a growth rate of almost 7% overall with a 1.5 change from the previous Quarter. And by Q4 of 2019, Golang has grown to an 8% overall increase.
Reasons Why Golang is so Popular?
- Go is a statically typed, compiled language; hence you can easily catch problems early on.
- Go compiles instantly to machine code, so it makes the edit/refresh cycle relatively fast, and still reasonably efficient machine code is produced.
- Go is designed in such a way that it makes it easy to write highly concurrent, networked programs.
- Go comes with a lot of built-in infrastructure to support testing; you can effortlessly define and test modules; this further strengthens engineering discipline.
- Go’s cross-platform hallmarks make porting code very easy, and this is the most significant advantage of Go.
- Go gives opinionated formatting, linting & vet tool as a default part of the package, and the Go compiler even enforces things like unused variables. This makes it a professional language.
- Go’s native support for concurrency and parallelism is what makes it so special. This makes Go a perfect language for applications that require heavy concurrent and/or parallel processing, networking, massive computing, etc.
- Go is the best for cloud compatibility. Go is featured with a better garbage collection facility, good network package & solving the problem of unused variables, multi and cross-culture compilers.
Practical Cases
1. SendGrid moved to Go
SendGrid, a customer communication platform, decided to move to Go as its primary development language long back in 2014. The SendGrid team needed to make a fundamental shift in their development language, and it boiled down to a competition between Scala, Java, and Go. The biggest challenge that SendGrid faced in development then was concurrent programming. Having the idea of concurrent asynchronous programming as part of the language was one of the most compelling reasons why Go was chosen at SendGrid.
2. Hexac switched from Python to Go
Tigran Bayburtsyan, the Co-Founder and CTO at Hexac, writes an exclusive article where he shares why his company moved from Python to Go. Based on their code base statistics, after rewriting all their projects in Go, they got 64% less code than they had earlier. They saved a lot of resources (Memory, CPU) because of the built-in language features of Go.
Go gave their development team huge flexibility, single language for all use cases, and for all of them, it worked very well. At Hexact Inc, they got about 30% more performance on their backend and API services. Now they can handle logging real-time, transfer it to the database, and make streaming with Websocket from single or multiple services. This is an outstanding outcome from using Go language features.
3. Salesforce ditched Python for Go
Before launching Einstein Analytics in 2017, Salesforce renewed the backend and entirely rebuilt it on Google’s popular Go language. Salesforce principal architect Guillaume Le Stum stated that ‘Python fails to do multi-threading well, while Go, is built for heavy applications suitable for Google’s production systems, the language has been tested and approved by Google, so Salesforce chose to shift Einstein Analytics, the vital part of Salesforce, from a hybrid C-Python application to a completely Go application.
4. Containerum chooses to Go over others
Containerum, a container management platform been using Go as their primary language for about four years now, and despite certain challenges, the engineering team thinks it is a good choice. The main reason to choose Go at Containerum Platform is that it consists of a group of smaller services that communicate with other components of the system. To ensure this, it is highly necessary to secure interface compatibility and write code that is too simple, easy to read and maintain.
Go enables adding patches and allows using ready components in the code base, e.g., image names parsing validation, key object models, etc. and this is one of the reasons Containerum chose Go. Containerum considered Go over other languages because of its many Pro features/facts such as static typing, minimalism, standard library, fantastic performance, super-fast compilation, and much more.
5. Popular DevOps tools are written in Go
The giant company Google considered writing Kubernetes in other languages, including but according to Joe Beda, co-founder of Kubernetes, none of these languages were as effective as Go. There were many reasons why Kubernetes is written in Go. Some of them include – great libraries, fast tools, built-in concurrency, garbage collection, type safety, etc. According to Joe, the patterns and tools in Go have encouraged the Kubernetes team to make well-factored and reusable code that will give them both a high degree of flexibility and velocity at the same time.
Docker has been the biggest user of Go. The team at Docker liked to Go because it offered them many benefits: static compilation with no dependencies, neutral language, a full development environment, extensive strong standard library, and data types, strong duck typing, and the ability to build for multiple architectures with minimal nuisance.
Istio, part of the Kubernetes ecosystem, is also written in Go. Since Kubernetes was also written in Go, it was a perfect approach for Istio to write in Go. That is not just one reason, among many, Go’s suitability for decentralized, distributed networking projects was one of the main reasons to choose Go at Istio.
If you’re programming your applications in GoLang, how hard is it to practice CI/CD? Pretty hard, isn’t it? Well, not now. With the latest innovations in Go, like Go Center GOPROXY, the path to quality CI/CD is much clearer. GoCenter is a central public collection for immutable Go modules. It allows you to search for modules and versions, also you can easily add your modules to it to be shared publicly.