Has the Time Finally Come for Generics in Golang?

image

An anonymous reader quotes technology columnist Mike Melanson:

The debate around adding generics to the Go programming language has been going on for years now, often with much resistance, but it’s starting to look like one proposal finally has some backing and general acceptance from the greater Go community — much to the surprise of some involved.

Introduced this week in a blog post looking at the next step for generics, penned by Golang team members Ian Lance Taylor and Robert Griesemer, the first update in nearly a year on the topic explains that the generics design draft previously submitted for feedback has been refined, resulting in an updated design draft… For the time being, the team has introduced an experimentation tool that “permits people to type check and run code written using the version of generics described in the design draft” by translating generic code into ordinary Go code. It is meant to give users a feel of how the proposed design would, if accepted work, and they note that it will be implemented differently if so.

As for the proposal itself, it offers several levels of detail, from an abstract, to a high-level overview, to the full level of detail you might expect from such a document. As with everything Go, the design is intended to be fully backward compatible with Go 1, and the authors note that "as the term generic is widely used in the Go community, we will use it below as a shorthand to mean a function or type that takes type parameters.

“Don’t confuse the term generic as used in this design with the same term in other languages like C++, C#, Java, or Rust; they have similarities but are not the same.”
The article also notes that Go’s package repository is now open source.

2 Likes