Go quietly entered the world outside of Google in 2009. At the time, it was described as a “20%-time project” to build a better C++. Along the way, the language has won over many new fans who claim it offers an easier way to write massively scalable applications.
Today, the language is available as version 1.0.2, and the development world is abuzz at the prospects of this concurrent, garbage-collected language. Mark Summerfield, a development consultant and author, became so enamored with Go that he wrote a book on the language, titled “Programming in Go: Creating Applications for the 21st Century.”
“I read the specification early on within a few weeks of them announcing it publicly, and it just grabbed me,” he said. “It was an interesting spec, it was clear and understandable. You could see some of their sources: It’s C-oriented, but they’ve also given you some high-level stuff. Maps are like Python dictionaries. Slices are like Python lists.”
But the final straw for Summerfield, a longtime C++ developer, was when he saw C++11. “I’ve been searching for a long time for an alternative to C++, because C++ is getting harder and harder to be a master of,” he said. “With C++11, you’ve got to be a guru. It has loads of great new things, but it gives you a huge language, and they haven’t deprecated enough. For example, they introduced tuples, but didn’t deprecate pairs. You can use tuples instead of pairs if you want. They should have deprecated some of this stuff because they do better things now. C I find too frustrating, too low-level. I thought Go looked like a nice candidate there. I started with Perl, Ruby, TCL and JavaScript, but Python is it for me. I wanted to find that in the compiled world.”
Taking its lead from C++ and Python, Go has gathered a following among programmers who’ve had many of the same complaints as Summerfield. Andrew Gerrand, developer relations lead for Go at Google, said that “The response to Go has been phenomenal. Since the open-source launch in 2009, the project has attracted hundreds of contributors, and developed a growing ecosystem of libraries and tools. A vibrant community of Go users has sprung up to support the language. This is impressive growth, especially when compared to the trajectory of today’s mainstream languages.”
The language itself has been hugely influenced by the community that’s adopted it, said Gerrand. He stated that sweeping changes proposed for version 1.0 were shown to the community, then altered based on weeks of debate and discussion.
Outside of Google, Go is already in use at the BBC, Heroku, Pixar and ngmoco. They come to the platform not only because of its capabilities, but also because of the openness Google has had with the language.
“The biggest win brought by Go 1 is stability,” said Gerrand. “Our compatibility promise means that programs written today for Go 1 will continue to build with Go version 1.x. Go 1 is a refined and reliable foundation on which to build modern software, and will remain so for years to come.”
But Summerfield said there’s another big draw for Go: Unicode support. “The thing that really made me interested was it had really good Unicode support for UTF-8,” he said.
“In C++11, they shoved in the ability to have Unicode strings, but there’s nothing to manipulate them. You can waste memory by using UTF-32 in C++ [to manipulate Unicode strings]. If you have Asian characters, that forces you into UTF-32. All the string stuff in C++ is geared up for characters of standard width. Go got it right. You can read in UTF-8, 16 or 32. It has native support for UTF-8, but they don’t disguise the fact they know there are bytes and characters.”
All these benefits pale in comparison to the central feature of the language: concurrency. Said Gerrand, “The primary usability benefit of Go over C, C++ and many other languages is its native concurrency support. Most networked software systems are based around concurrent processes, and Go’s goroutines and channels let you model such concurrent processes in a natural and straightforward way. We’ve seen complex, hard-to-maintain C++ programs rewritten as almost trivial Go programs, mostly because of these concurrency primitives.”
Goroutines, said Summerfield, are a breath of fresh air for building concurrent software. “Go will multiplex those goroutines onto as many threads as it deems appropriate. That could be one thread per 10 goroutines, or one thread per thousands of goroutines. Go takes care of it. It also does garbage collection. In single-threaded programs, memory management is no problem, but as soon as you go threaded, then you’ve got real issues about the lifetime of objects. The garbage collector understands goroutines. This takes away the huge burden of bookkeeping.”
Go, then, seemingly is on the way to becoming routine for enterprises seeking scalability.