
Why developers love Go – SD Times
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.Ā
Go also has an advantage over older languages because decades ago when languages like Python, Java and JavaScript were developed, no one could have imagined how the world and technology would evolve. For instance, Francia explained pretty soon Mooreās Law will be coming to an end, and we will no longer have single-core machines. Go has concurrency baked in, making it easier to program on multiple cores and multiple threads.Ā
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.Ā Look at Java, which is now so large that no one person could possibly understand it all or use it properly,ā said Youngman.Ā
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.ā
Credit: Source link