Why use Golang?

10th May 2017

Golang has been called:

a programming language made in the heavens

unapologetically flawed

doomed to succeed.”

Most importantly our CTO at Amigo, Jacob Clarkson, uses Go because he shares its philosophy. Jacob and Go prize “clarity over supposedly ‘clever’ code.”

What is Golang?

Go, often styled Golang for easier searching, is a programming language guided by simplicity. It is:

  1. Compiled
  2. Concurrent
  3. Statically-typed
  4. Garbage-collected
  5. Efficient
  6. Scalable
  7. Readable
  8. Fast
  9. Open-source

Who created Golang?

Go was written from scratch 10 years ago at Google by Rob Pike, Robert Griesemer, and Ken Thompson. They had become frustrated with the unnecessary complexity of available programming languages, deeming them “too subtle, too intricate, and far too verbose.”

The story goes that Go was created during an excessively long wait the developers were having for some C++ code to compile. Out of this frustration they created a language for the modern computing landscape.

Why is Golang so fast?

The benefits of hybridity

Go is an attempt to combine the ease of programming of an interpreted, dynamically-typed language with the efficiency and safety of a statically-typed, compiled language. It’s easy and enjoyable to work with but also does a lot of the useful things a statically-typed language does, such as picking up errors at compile time.

In Jacob’s words, despite it being statically-typed Go “feels like a dynamic language” and while Go “looks simple, under the hood it’s complicated.” This echoes its original developer’s point that “simplicity is complicated.” For Clarkson even though some might say that Go “looks like a language from the 80s,” it is precisely by “not trying to reinvent the wheel” that Go benefits from a long history of accumulated programming knowledge.

Go’s ability to produce a single binary also shouldn’t be underrated. Java can get to a single file but will require a virtual machine to execute. Again Go wins on simplicity.

Compilation

Compilation efficiency was prized by the Go creators and as a result they designed a language that exhibits impressive build times. Here again simplicity plays a key role, as Go avoids slowing down the compiler by avoiding some of the pitfalls of other languages. For example C++’s re-reading of header files slows its compile time, whereas Go’s dependency management works across modules and cuts out all that extra work.

The release of Go 1.8 came with an expected 15% improvement in compilation times, something that the team was keen to address after compilation times had begun to lengthen after Go 1.4. They also announced that they would continue to focus on bringing down compile times in their future releases.

Execution

Go is a fully garbage-collected language and in some languages garbage collection can harm the speed of execution. However Go’s team have worked on this. In Go 1.8, pauses for garbage collection are “usually under 100 microseconds and often as low as 10 microseconds.”

For more technical explanation of Go’s speed, see this post by Dave Cheney.

Working in Go

Go has a full development environment that developers generally find easy to work in quickly, finding many potential issues addressed by useful commands such as go doc, go get, go test, and go run.

Go’s intended simplicity makes it easy to learn and therefore accessible for inexperienced programmers. It also has a rich tooling ecosystem that accelerates the speed at which one can get to grips with the language. This makes it ideal for large collaborative projects.

What is Golang good for?

Generally, Go is great for any project requiring simplicity and performance however it also has some powerful and specific benefits.

Concurrency

Concurrency is a first-class citizen within Go. It was designed at Google to handle their increasingly large projects and by using goroutines where a language such as Java uses Threads, it can handle huge projects efficiently. Tens of thousands of goroutines can run concurrently and Go still performs with impressive speed.

Cloud

This emphasis on concurrency, combined with the fact that Go was designed for server software and to solve “Google-sized problems,” creates a language particularly suited to cloud computing. This is one of the reasons projects such as Docker choose Go and also one of the reasons Go continues to grow in popularity as the cloud becomes increasingly dominant.

Who uses Golang?

Go has become increasingly mainstream since its open-source release in November 2009, having been used in numerous successful projects.

A large part of this is driven by its community. Go works well within distributed teams (e.g. on GitHub) for a number of reasons, chief among which is Gofmt – a tool which takes any valid Go code and prints it in a standard format. Although developers will always have their own preferred style (indeed Robert Griesemer, who wrote the tool, prefers his code to be formatted in a different way!) the value of a consistent canonical styling of Go code means, in Rob Pike’s words: “Gofmt’s style is no one’s favorite, yet gofmt is everyone’s favorite.”

Go also actively promotes a friendly, diverse, and accessible community. In its 2016 User Survey Go found that 19 out of every 20 users would recommend Go and that an overwhelming majority of users felt welcome in the Go community.

From a technical perspective, Rob Pike writes that the developers migrating to Go are more likely to be Ruby or Python developers than they are C++ developers. He credits this to the increase in performance that Ruby and Python developers receive without sacrificing much in the way of expressiveness. C++ developers on the other hand retain a strong philosophical attachment to their language and have so far remained untempted by the plucky upstart.

Why does Amigo use Golang?

There is a clear affinity between the values underpinning Go and the values underpinning Amigo Technology. Both aim to create surface level simplicity by getting all the complicated stuff to work “under the hood.” Where Amigo tries to make life easier for marketing departments with simple, powerful, enabling technology, Go tries to make life easier for development teams.

This spirit in both Amigo and Go was born out of frustration with the unnecessary and unhelpful complexity present in the mainstream of their respective fields. Both ultimately create progress through simplicity and make ever more powerful technology enabling rather than oppressively complicated. Or perhaps, it’s as simple as Amigo being an anagram of “I am Go.”

Which other companies use Golang?

Go is used by many development teams, including:

Where to start with Golang?

If you’re inspired to take Jacob’s sage advice and want to learn Go then the best place to start is the official Tour of Go. Dave Cheney also has a good list of resources here. There’s also a very helpful community of Go programmers on Reddit.


If you share our enthusiasm for Go, have been converted or intrigued by this article, or just want to work with a fantastic and friendly team of developers, check out our vacancies!

Further reading

 

020 3940 4650