Go language


Generics, which programming allows for the representation of functions and data structures in a generic form, could arrive in Go 1.17, due for release in August 2021.

While the plan to introduce generics to the programming language was initiated by the Go project developers with a draft for type parameters to replace contracts with interface types.

The developers also introduced a transition tool to enable the translation of generic code. As the authors of the design draft discovered that the difference between contracts and interface types was a bit confusing, so they eventually dropped the contracts plan.

What generics can bring to Go language



The most important capability of generics in Go is to write functions like Reverse without minding the element type of the slice. Then developers can write the function once, also write the tests, put them in a go-gettable package, and call them up whenever they want.

Even better, since this is open source, someone else can also write Reverse once, and it can be used by others to implement theirs.

Given that Go language has two general-purpose generic data structures built into it: slices and maps. With slices and maps able to hold values of any data type, and static type checking for values stored and retrieved. The values stored are not as interface types.

What's the next step for Generics in Go language?



The Go project developers released an updated design draft for type parameters on June 16, which draft replaces contracts with interface types. And the type parameters are now constrained by interface types, while interface types can include type lists, albeit only when used as constraints.

They promise to continue to adjust it as they learn more, from their experiences and that of the community, what works and what doesn’t. If they reach that goal, then it’ll be something that can be proposed for future versions of Go. Hopefully, the generics capability will potentially arrive with Go 1.17 in August 2021, if all goes well.

Go language moving forward with Plans to introduce Generics

Go language


Generics, which programming allows for the representation of functions and data structures in a generic form, could arrive in Go 1.17, due for release in August 2021.

While the plan to introduce generics to the programming language was initiated by the Go project developers with a draft for type parameters to replace contracts with interface types.

The developers also introduced a transition tool to enable the translation of generic code. As the authors of the design draft discovered that the difference between contracts and interface types was a bit confusing, so they eventually dropped the contracts plan.

What generics can bring to Go language



The most important capability of generics in Go is to write functions like Reverse without minding the element type of the slice. Then developers can write the function once, also write the tests, put them in a go-gettable package, and call them up whenever they want.

Even better, since this is open source, someone else can also write Reverse once, and it can be used by others to implement theirs.

Given that Go language has two general-purpose generic data structures built into it: slices and maps. With slices and maps able to hold values of any data type, and static type checking for values stored and retrieved. The values stored are not as interface types.

What's the next step for Generics in Go language?



The Go project developers released an updated design draft for type parameters on June 16, which draft replaces contracts with interface types. And the type parameters are now constrained by interface types, while interface types can include type lists, albeit only when used as constraints.

They promise to continue to adjust it as they learn more, from their experiences and that of the community, what works and what doesn’t. If they reach that goal, then it’ll be something that can be proposed for future versions of Go. Hopefully, the generics capability will potentially arrive with Go 1.17 in August 2021, if all goes well.

No comments