Originally posted on sdtimes.
The open source Go programming language, also known as Golang, has worked to simplify developer lives since it first appeared in 2009.
While it may have been Google’s backing that gained developers’ attention, its efficiency, simplicity and tooling are the reason developers keep coming back, according to Nathan Youngman, author of Get Programming with Go. He explained that efficiency equates to fewer servers, which is good for business. Simplicity and familiarity mean it’s easy to learn. And the tooling means more uniform code, making it easier to understand.
Last year, the Stack Overflow developer survey reported that Go was the fifth most loved programming language, moving up from the 10th spot the previous year. It is also the third most wanted language among developers who aren’t using it, but are interested in it.
According to the language’s 2019 annual developer survey, the reason more developers don’t use it is because they are working on a project in another language, their team prefers another language, and the lack of critical features doesn’t make it suitable for their needs. However, the number of developers that prefer a different language is decreasing every year. Eighty-nine percent of respondents indicated they want to use Go for their next project, and 86% who are using it reported it is working well for their teams.
What makes Go special?
The beauty of Go has more to do with its lack of features than its actual features, according to Jonathan Bodner, distinguished engineer at Capital One. He explained it’s intentionally small and tries to be boring. “It’s not the prettiest language, or the one with the most features, but its focus on maintainability, testability, repeatable builds, and developer productivity gives it the right priorities for modern cloud development,” Bodner said.
According to Steve Francia, product and strategic lead for Go at Google, Go grew out of the need for simplicity. Programming languages were starting to get more and more complex and the readability was becoming untenable. When you have hundreds of teams working on the same codebase, much like Google does, readability is crucial. “One of the big catalysts for Go was to create a language that was simple, easy to read, easy to scale up on a human basis,” said Francia.
This is important because coding is a team sport, according to Thomas Limoncelli, SRE manager at Stack Overflow. “Devs spend more time reading existing code and updating it than writing new code from scratch. Code readability is undervalued in this industry. Google culture encourages engineers to change teams frequently (every 1.5-3 years). Therefore code readability is highly valued,” he said.
Limoncelli explained Google’s backing also didn’t hurt the language’s rise in popularity. “As a company grows they face more and more problems that Google faced years ago. It’s nice to have a trailblazer that cleared the way,” he added.
Starting a language from scratch enabled the programming language’s team to learn and be inspired from other languages. “Making a new language allows for a reset. For example, C++ classes support multiple inheritance, whereas Java has interfaces and single-inheritance, and Go has interfaces but no inheritance,” said Youngman. “Such a reduction takes a best practice from other languages and makes it the ‘one way to do it.’ Simplifying the language in this way may benefit other aspects of the implementation, such as improving compile times.”
Luck and the right timing also had a lot to do with Go’s success, according to Google’s Francia. “[Go] happened to hit the right set of features at the same time the cloud was emerging, and as a result a lot of cloud native stuff (Docker, Kubernetes, Istio) was written in Go,” he said. “That was the incubation moment where it proved this wasn’t a research language, that it had practical use and that allowed it to cross into the mainstream.”
Since so many cloud development tools are written in the language, as companies move to the cloud and rethink their development stacks, they are starting to investigate the language, according to Capital One’s Bodner.
The language’s concurrency support “allows people to think about concurrency as data flowing through a system, with goroutines processing data that’s passed in and out via channels, with the data flow managed by select statements,” Bodner explained.
Other key features of the language include its fast compiler, which allows developers to get rapid feedback; its standard library and compatibility guarantee; and its implicit interfaces that enable duck typing while enforcing type safety, according to Bodner.
Areas for improvement
With the variety of programming languages available for developers to learn, some languages are better than others for certain things, and Go is no exception. Capital One’s Bodner explained better immutability in Go would make it easier to understand how data flows through a program. “There are techniques that you can use in Go programs to mitigate this, but it’d be nice if there was a way to tag a value as immutable and have the compiler validate this,” he said.
Stack Overflow’s Limoncelli explained that while Go is very good at error handling, it can be verbose. “It would be nice to have a more concise syntax for dealing with errors,” he said. In addition, Go is aggressive about dropping support for older operating systems, and best suited for servers and systems that are updated frequently.
Youngman also noted that type parameters for generic programming “could open the floodgates for new kinds of libraries without sacrificing type safety.”
Google’s Francia added that GUI-based objects are more challenging in Go, and that Go is not a scripting language, so there may be places where developers want to script and Go isn’t the best fit.
“The best part about Go is what it leaves out. It doesn’t try to be the end-all, be-all, language for every situation. It tries to be very good at one thing (server and back-end code). People often complain that it is missing a feature (Generics, functional operations, etc.) but keeping the language small is good,” Stack Overflow’s Limoncelli said.
Where is Go going?
Some of the top requests users have asked for over the last couple of years include better dependency management and generics.
According to Google’s Francia, the introduction of modules two years ago changed the Go developer tooling landscape, and made it easier to manage dependencies. The first production-ready implementations of the Go modules were released last year with Go 1.14, and the team now encourages users to migrate to Go modules for dependency management.
Generics would allow developers to write more reusable code than the language allowed previously. This is something Francia said the company has been trying to get right for over a decade, and now they believe they finally have a plan to allow generics that don’t introduce complexity and give users more features. “Generics can give us powerful building blocks that let us share code and build programs more easily. Generic programming means writing functions and data structures where some types are left to be specified later. For example, you can write a function that operates on a slice of some arbitrary data type, where the actual data type is only specified when the function is called. Or, you can define a data structure that stores values of any type, where the actual type to be stored is specified when you create an instance of the data structure,” Ian Lance Taylor, Go programming team member, wrote in a post.
In the beginning of the year, the team filed a change proposal to support type parameters for types and functions, which would permit a form of generic programming. The proposal was officially accepted in February and moved to a work milestone. According to Francia, implementing this feature will be a main focus for the rest of the year, as well as better security and performance — which is something the team works on in every release.
“The proposed implementation follows the Go philosophy. It’s just enough generics to solve developer pain points, but leaves out features that are interesting but would unnecessarily complicate the language,” said Capital One’s Bodner.
Other areas of improvement the team will be working on this year include helping users make better choices. For instance, the team provides insights to users into ecosystem packages and what packages may fit users’ needs best, as well as making users’ IDE experience better.
The team is also working on more ARM support. The upcoming release of Go 1.16 is expected to include a new file system interface and build-time file embedding as well as support for the new Apple Silicon Macs.
Lasty, the team has been working on what it calls “Go 2,” an ongoing effort to improve the language through incremental releases and proposal implementations.
“A major difference between Go 1 and Go 2 is who is going to influence the design and how decisions are made,” wrote Robert Griesemer, one the language’s main developers, in a blog post. “Go 1 was a small team effort with modest outside influence; Go 2 will be much more community-driven. After almost 10 years of exposure, we have learned a lot about the language and libraries that we didn’t know in the beginning, and that was only possible through feedback from the Go community.” Current proposals for Go 2 include adding a match statement, removing init functions, type parameter declaration and instantiation segregation, function values as iterators, and allowing type-parameterized methods.
“Go is far more than just us on the Go team at Google. We are indebted to the contributors who work with us with the Go releases and tools,” Go team member Russ Cox wrote in a post.
Go in action
Go is currently being used by a wide range of different companies and industries — from Google, Microsoft, and Facebook to American Express, Capital One, Target and Netflix, these companies are using Go to power their software and services.
Google, which designed Go, is using the language in its core data solutions, Chrome content optimization service, and within the Firebase Hosting team.
Microsoft has been using Go to power aspects of its cloud infrastructure such as the Azure Container Service, and has been working to help developers build apps for Azure with Go with the Azure SDK for Go. “One of the advantages of using Go with Azure, I think, is the speed at which you can develop—the speed at which Go executes,” according to Brian Ketelsen, cloud advocate at Microsoft. “It’s a really fast language. And that awesome ability to create a single static binary: you don’t have the craziness of worrying about dependencies when you build your applications with Go.”
Financial companies like American Express and Capital One use Go in their microservices to improve speed and productivity, and serverless initiatives.
Facebook recently decided to write a new ORM in Go with the ability to define any data model or graph structure easily.
Lastly, Netflix is using Go for application data caching because it needed something with lower latency than Java, but more developer productivity for developers. Meanwhile, Target recommends Go for its simplified syntax, mature and well-built libraries and external community.
“When we first released Go to the public in November 2009, we didn’t know if the language would be widely adopted or if it might influence future languages,” Rob Pike, one of the creators of Go, wrote on its website. “Looking back from 2020, Go has succeeded in both ways: it is widely used both inside and outside Google, and its approaches to network concurrency and software engineering have had a noticeable effect on other languages and their tools.
“Go has turned out to have a much broader reach than we had ever expected. Its growth in the industry has been phenomenal, and it has powered many projects at Google.”