Why Is Go Good? |
Written by Mike James |
Monday, 30 May 2022 |
The five co-creators of the Go language, Russ Cox, Robert Griesemer, Rob Pike, Ian Lance Taylor and Ken Thompson, have co-authored a paper in this month's edition of Communications of the ACM in which they address the question, Why has Go grown in popularity when so many other language projects have not? As outlined in The Go Programming Language and Environment which is freely accessible online, Go was created at Google in late 2007 and released as open source in November 2009. Since then, it has operated as a public project, with contributions from thousands of individuals and dozens of companies. It is a garbage-collected, statically compiled language with support for concurrency and parallelism, which helped take advantage of the multicore machines that were becoming mainstream during its early years. It initial popularity must have been helped by its Google connections. Image Source: ACM.org Nowaday's Go can justifiably be regarded as the language of the cloud. As the paper states, Go is the foundation for critical infrastructure at every major cloud provider and is the implementation language for most projects hosted at the Cloud Native Computing Foundation. Posing the question of why Go remains a success when other languages have failed the authors state: We believe that the language itself forms only a small part of the answer. The full story must involve the entire Go environment: the libraries, tools, conventions, and overall approach to software engineering, which all support programming in the language. The most important decisions made in the language's design, then, were the ones that made Go better for large-scale software engineering and helped us attract like-minded developers. The article goes on to examine the design decisions its co-creators believe are most responsible for Go's success, exploring how they apply not just to the language but also to the environment more broadly. Concurrency is one of the aspects it focuses on explaining: When we started designing Go, multi-core computers were becoming widely available, but threads remained a heavyweight concept in all popular languages and operating systems. The difficulty of creating, using, and managing threads made them unpopular, limiting access to the full power of multicore CPUs. Resolving this tension was one of the prime motivations for creating Go. It then outlines how Go implements the concept of multiple concurrent threads of control with goroutines, which run in a single shared address space and are multiplexed onto operating system threads. A call to a blocking operation, such as reading from a file or network, blocks only the goroutine doing the operation; other goroutines on the thread may be moved to another thread so they can continue to execute while the caller is blocked. The paper moves on to Go's approach to security and safety, areas in which it set out to address the deficiencies of previous languages, explaining: Go removes undefined behaviors that cause so many security problems in C and C++ programs. Integer types are not automatically coerced to one another. Null pointer dereferences and out-of-bounds array and slice indexes cause runtime exceptions. There are no dangling pointers into stack frames: Any variable that might possibly outlive its stack frame, such as one captured in a closure, will be moved to the heap instead. There are no dangling pointers in the heap either; the use of a garbage collector instead of manual memory management eliminates use-after-free bugs. Consistency was another goal for Go and the discussion returns to garbage collection in this context noting improvements over time: Consistent performance includes the overhead of garbage collection. The original Go prototype used a basic, stop-the-world garbage collector that, of course, introduced significant tail latency in network servers. Today, Go uses a fully concurrent garbage collector with pauses taking less than a millisecond, and usually just a few microseconds, independent of heap size. The article's conclusion opens with a paragraph that highlights how its approach to writing programs contributed to its success: Although the design of most languages concentrates on innovations in syntax, semantics, or typing, Go is focused on the software development process itself. Go is efficient, easy to learn, and freely available, but we believe that what made it successful was the approach it took toward writing programs, particularly with multiple programmers working on a shared codebase. The principal unusual property of the language itself—concurrency—addressed problems that arose with the proliferation of multicore CPUs in the 2010s. But more significant was the early work that established fundamentals for packaging, dependencies, build, test, deployment, and other workaday tasks of the software development world, aspects that are not usually foremost in language design. There is a lot more to say but if you are interested read the full paper. More InformationThe Go Programming Language and Environment by Russ Cox, Robert Griesemer, Rob Pike, Ian Lance Taylor, Ken Thompson Related ArticlesGo 1.18 Released With Generics And Fuzzing A Decade of Go - Google's Systems Language Go Rejects The Syntactic Sugar Of Try To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
Last Updated ( Monday, 30 May 2022 ) |