Category: Google|Jun 28, 2020 | Author: Admin

google's go language could get generics in 2021

Share on

Generics have been requested by Go programmers for years for the simplicity and flexibility they offer

Generics have been requested by Go programmers for years for the simplicity and flexibility they offer

Developers of Google’s Go language are moving forward with plans to introduce generics into the language, with the capability potentially arriving in August 2021, if all goes well. The lack of generics, meaning a function or type that takes type parameters, frequently has been cited as a shortcoming of Go. 

Generics would be included in the Go 1.17 release, due at that time. But that timeline was described as optimistic by Go project developers, who noted unforeseen problems could arise. Generic programming enables the representation of data structures and functions in a generic form, with types factored out. It has been viewed as a mechanism to make some programming tasks simpler but there have been concerns that it could complicate the language.

[ Also on InfoWorld: 10 open-source projects proving the power of Google Go ]
Go project developers on June 16 released an updated design draft for type parameters that replaces contracts with interface types. They also introduced a transition tool to help to translate generic code. The design draft authors found that the difference between contracts and interface types was confusing, so they dropped the contracts plan. Type parameters are now constrained by interface types, while interface types now can include type lists, though only when used as constraints. Authors of the updated draft hope developers will find it easier to understand.

The transition tool, available in a variant of the Go Playground, permits type checking and running code written using the version of generics described in the draft. The transition tool is intended to help the Go language developers decide how to further refine the draft; the tool translates generic code into Go code. While the translation process has limitations, Go’s developers hope the tool provides a glimpse of what generic Go code might look like and learn whether generic code makes sense. 

The next step for generics in Go could be a formal language change proposal. Go’s developers are in the early stages of sketching out a direct compiler implementation. Also, the Go project developers have written a type checker, a program that can parse Go code that uses generics as described in the draft and report type errors. An example code has been written.

Go originally was released in November 2009. Go 1.15 was released in beta form last week. The production release of Go 1.15 is expected in August.

Sponsored Ads:

Comments:


Nebraska Man pleads guilty to $3.5 million cryptojacking scheme

Category: IT|Dec 6, 2024 | Author: Admin

Microsoft says having a TPM is "non-negotiable" for Windows 11

Category: Microsoft|Dec 5, 2024 | Author: Admin

Japan warns of IO-Data zero-day router flaws exploited in attacks

Category: IT|Dec 4, 2024 | Author: Admin

Korea arrests CEO for adding DDoS feature to satellite receivers

Category: IT|Dec 3, 2024 | Author: Admin

Google Chrome’s AI feature lets you quickly check website trustworthiness

Category: Google|Dec 2, 2024 | Author: Admin

Novel phising campaign uses corrupted Word documents to evade security

Category: IT|Dec 1, 2024 | Author: Admin

SpyLoan Android malware on Google play installed 8 million times

Category: Google|Nov 30, 2024 | Author: Admin

New Windows Server 2012 zero-day gets free, unofficial patches

Category: Microsoft|Nov 29, 2024 | Author: Admin

Microsoft re-releases Exchange updates after fixing mail delivery

Category: Microsoft|Nov 28, 2024 | Author: Admin

Cloudflare says it lost 55% of logs pushed to customers for 3.5 hours

Category: IT|Nov 27, 2024 | Author: Admin

Hackers exploit critical bug in Array Networks SSL VPN products

Category: IT|Nov 26, 2024 | Author: Admin

Microsoft 365 outage impacts Exchange Online, Teams, Sharepoint

Category: Microsoft|Nov 25, 2024 | Author: Admin

Meta removes over 2 million accounts pushing pig butchering scams

Category: IT|Nov 24, 2024 | Author: Admin

Hackers abuse Avast anti-rootkit driver to disable defenses

Category: IT|Nov 23, 2024 | Author: Admin

Windows 11 KB5046740 update released with 14 changes and fixes

Category: Microsoft|Nov 22, 2024 | Author: Admin
more