Home United States USA — software Go 1.9 Introduces Type Aliases, Improves Runtime and Tooling

Go 1.9 Introduces Type Aliases, Improves Runtime and Tooling

324
0
SHARE

The biggest change in recently released Go 1.9 is improved support for gradual code repair through the use of type alias declarations. Go 1.9 also improves the garbage collector and the compiler.
The biggest change in recently released Go 1.9 is improved support for gradual code repair through the use of type alias declarations. Go 1.9 also improves the garbage collector and the compiler.
Gradual code repair, as explained by Google engineer Russ Cox, is a useful approach to code refactoring, mostly valuable with large codebases. In short, gradual code repair aims to carry through a large refactor in a series of steps, i.e., commits, as opposed to making all the changes atomically, i.e., in one single commit. The atomic refactor approach is usually simpler at a conceptual level, but with large codebases it can produce really big commits, which are hard to review and merge. With gradual code repair, you refactor your code in three steps: first, you introduce the new API, which should be able to coexist with the old API, so you do not need to change all uses of the old API at once; second, you convert all uses of the old API to the new API; finally, you can remove the old API.
To enable gradual code repair, it must be possible to create alternate names for constants, functions, variables, and types. Now, Go allows to define a type alias using a declaration like:
This can be used to make all references to OldAPI automatically use the refactored type. For a broader discussion of gradual code repair, do not miss Russ Cox’s exposition.
As explained by Google engineer Francesc Campoy, most engineering effort for Go 1.9 went into improvements of the runtime, core library, and tooling. The most significant changes are:
To learn about all the changes that went into Go 1.9, make sure to read the official release notes .

Continue reading...