Go 1.5, released today, improves the Google-developed language by adding concurrent garbage collection, leveraging all processor cores by default, and letting developers use Go to write background logic for mobile apps.
The up-and-coming open source language, which boasts Docker as a marquee application that has used it, is well-suited for network applications and command-line apps. Version 1.5 is the sixth major stable release of the language.
"With Go, we're trying to make programmers more productive, and the way that we chose to do that was build a working a system, a working programming language stack," said Russ Cox, Google principal engineer for Go, in an interview.
The concurrent garbage collector improves latency by making pauses incurred by the collector while the program runs much shorter, Cox said. Now, Google is seeing pauses in the range of 10 to 20 milliseconds for a 10GB program, as opposed to a 1-to-2-second pause.
Version 1.5 also has its language runtime and compiler rewritten in Go, converted from the C language. This creates tighter integration between the parts of the language: Written in Go, the compiler already knows about Go concepts, such as garbage collection. Converting the runtime to Go enabled the changes to garbage collection.
Developers using Go 1.5 will no longer have to specify use of processor cores; this will be done by default via the scheduler. "The garbage collector and the main program can run on different threads and different cores," Cox said.
With Google's "Go mobile experiment," leveraged in the upgrade, developers can write a C program that calls Go as a library; version 1.5 also features new operating system and architecture ports for darwin/arm64 and linux/arm64. The combination of being able to call Go from C or C++ programs and having a port for Darwin on ARM enables the Go mobile experiment, which is "exploring the use of Go as an NDK (Native Development Kit) language, a native language on mobile devices that are running both Android and iOS," Cox said.
Go could be used as an NDK language to write background network logic for Android and iOS applications. Many apps, especially games, have Java or Objective-C running the UI, but native code is used to run the main logic of the game or app, Cox said. "The idea here is where you're using C++ today, you could use Go, instead."
The release also features experimental support for ppc64 and ppc64le (IBM PowerPC 64-bit, big and little endian), and internal developer tools have been improved. Support for "internal" packages permits sharing of implementation details between packages, while experimental support for "vendoring" external dependencies serves as a step toward a standard mechanism for managing dependencies in Go programs. Vendoring pertains to copying source code written by others into the developer's own source tree, to have some control over it.
Version 1.5 features a
go tool trace command, which enables visualization of program traces generated by a new tracing infrastructure in the runtime. A
go doc command, meanwhile, serves as a substitute for the original
godoc command that provides an improved command-line interface.
The lone language change was the lifting of a restriction in the map literal syntax, to improve succinctness and offer consistency with slice literals. Standard library improvements in Go 1.5 include cleaner usage messages in the flag package and a Float type in the math/big package, for computing with arbitrary-precision floating point numbers. An improvement to the DNS resolver on Linux and BSD systems removes the cgo requirement for programs that perform name lookups.
This story, "Google Go goes faster with 1.5 upgrade" was originally published by InfoWorld.