Why Do People Use Go ?
People use Go programming language for various reasons. Here is all reasons in brief:
- Go is open-source but backed up by a large corporation (Google)
- Itโs fast:
- to learn
- to build up
- to compile
- to arrange and install
- to scamper
- Go is a modern language
- Go is Simple
- It is Concurrent
- Static code analysis
- Garbage collected language
- Testing Support
And now, let’s dive in each reason.
Performance ๐
Most people come to Go from dynamic languages like Ruby, Python, JavaScript, PHP and other similar languages. Usually, the main reason for the switch is performance and memory efficiency. Go is one of the most efficient languages at this time which is also relatively easy to pick up and get productive with quickly. Itโs far from the most efficient ones but itโs probably one of the best when it comes to the balance between performance and convenience.
Concurrency ๐
Concurrency has become one of toughest problems of modern programming, especially when it comes to networking software. Go was designed with concurrency and multi-core systems in mind. Itโs not a revolution in concurrent programming but Goroutines and channels make concurrency way easier to handle! People coming from single-threaded environments are advised to learn the basic concepts of multi-threaded programming (data races, locks, lock-contention, lock-free structures, etc.) before even touching goroutines but they usually pick it up relatively quickly with Go because you usually canโt even get around it.
Simplicity and consistency as core language features ๐
Go was designed to avoid hidden complexity and keep code consistent and straightforward. Iโve seen people ditch large C++ codebases and rewrite the whole thing in Go because the C++ code became unmaintainable at some point while Go code tends to remain maintainable over time at a very slight cost of runtime performance (compared to C++). Itโs very common for people who initially started a thing to leave the company afterward and this can sometimes be a serious problem for codebases written in languages like C++ because of the diversity of these kinds of ecosystems. Go is a rather conservative language when it comes to features, code-style, and syntax-sugar making it one of the easiest languages to maintain codebases in.
No hidden complexity (no operator overloading, no function overloading, no setter/getter magic, no preprocessor, no const-expressions, no JIT-compilation, no abstract data-types, no implementation-inheritance, .. etc.)
No generics (Donโt get me wrong, generics arenโt bad, theyโre actually pretty useful in some cases but their absence does make code more simple often than not)(update: on Mar 15th, 2022, Go 1.18 added generics)A consistent code-style across the entire ecosystem via
go fmt
.Strong static typing (IMHO, strong static typing makes code simpler because it makes violating constraints rather difficult making code easier to read, test, change and refactor)
Tooling ๐
A programming language needs more than just a good design and a good compiler to be able to become relevant in the market. The toolset is essential to make a language successful and give people enough confidence to write production-grade stuff in it. Go comes with an excellent set of tools right out-of-the-box:
- The gofmt code formatter
- A data-race detector
- An excellent standard library
- The automatic [GoDoc] documentation hosting
- The Go Playground
- An execution tracer
- A built-in profiler
- Built-in benchmarking
- A huge number of community-maintained packages
- Several static code analysis tools like Go vet and golang-ci lint
- Goland , a Go-focused IDE
- The VSCode Go-plugin
- Several CI/CD systems which are free for open-source projects
Trustworthy Backers ๐
The fact that Go is not just designed and implemented by honored people like Ken Thompson but also backed and used by Google makes it easier to convince businesses to use Go in production. Go 1 keeps the backward compatibility promise and takes it seriously which makes it suitable for production-grade code.
Ecosystem & Community ๐
Thereโs a list of companies using Go but I think even though itโs relatively well maintained itโs still far from complete. The number of Go developers around the world is counted in millions and Goโs ecosystem is steadily growing . Thereโs plenty of material to make it easier for people to get started with Go like the Tour of Go , Go by Example and similar.
Fewer mistakes ๐
Most errors occur in unverified or complex code. Go provides convenient tools for testing. In addition, strict typing eliminates errors like a random comparison of the number of apples with the number of pears, which are determined at the compilation stage.