7 ms·
Out of curiosity, what changed between now, and when proposals for generics came up in years past?
by lastofus 6y ago
Out of curiosity, what changed between now, and when proposals for generics came up in years past?
- hnlmorg 6y agoThis isn’t a new proposal. Go’s maintainers have always been clear that they weren’t against generics per se but we’re against rushing into implementing something without giving sufficient time to consider the options. Personally I don’t think their time spent considering has resulting in anything better than if they had rushed into a solution (I’m not a fan of this proposal). But that’s just my personal opinion.
- meddlepal 6y agoYea basically they're implementing Java-lite generics. I'm not sure what they have been waiting for exactly...
- mseepgood 6y agoJava generics do type erasure, this proposal does not. Java generics do not work on primitive types or with operators, this proposal does. Java generics require unbounded parser look-ahead by using <>, this proposal avoids it by using []. These are just from the top of my head, I'm pretty sure there are more differences.
- skybrian 6y agoI'm not sure what you're comparing to, but there were previous proposals that were pretty different (and worse in my opinion), and there were changes along the way in the drafts that eventually turned into the accepted proposal.
- wwarner 6y agoThe main difference between the accepted proposal and the original proposal is that the original proposal introduced contracts and the accepted proposal folds all that functionality into interfaces.
- deleted 6y ago[deleted]
- mappu 6y ago> Go was released on November 10, 2009. Less than 24 hours later we saw the first comment about generics. - https://blog.golang.org/why-generics https://blog.golang.org/why-generics But it's just taken that long to come up with a good design. Most of the work has been pushed forward by core team member Ian Lance Taylor who put forward the case in https://github.com/golang/proposal/blob/master/design/15292-generics.md https://github.com/golang/proposal/blob/master/design/15292-... This abstract proposal has been updated to link to a summary of concrete proposals at the footer, ""presented for historic reference. All are flawed in various ways"" Type functions (June 2010) - https://github.com/golang/proposal/blob/master/design/15292/2010-06-type-functions.md https://github.com/golang/proposal/blob/master/design/15292/... Generalized types (March 2011) - https://github.com/golang/proposal/blob/master/design/15292/2011-03-gen.md https://github.com/golang/proposal/blob/master/design/15292/... Generalized types (October 2013) - https://github.com/golang/proposal/blob/master/design/15292/2013-10-gen.md https://github.com/golang/proposal/blob/master/design/15292/... Type parameters (December 2013) - https://github.com/golang/proposal/blob/master/design/15292/2013-12-type-params.md https://github.com/golang/proposal/blob/master/design/15292/... But it wasn't updated with implementation proposals after 2013, most notably Contracts (2019) - https://github.com/golang/proposal/blob/master/design/go2draft-contracts.md https://github.com/golang/proposal/blob/master/design/go2dra...