5 ms·
Go doesn't/didn't have generics? Why?
by cerved 5y ago
Go doesn't/didn't have generics? Why?
- jikbd 5y agoBecause features in software don’t exist until someone adds them.
- chrsig 5y agothis is a really underrated comment. there's always a lot of entitlement when it comes to software. why doesn't x have y? ...because x doesn't have y yet....this stuff doesn't build itself, and it certainly doesn't get built overnight.
- Redoubts 5y agoIt’s pretty overrated really (even if grey). Mature projects and PMs treat submitted code as liabilities to be maintained, not free benefits. And every project is at the whims of its maintainer, who can absolutely reject any contribution they wish. To suggest generics weren’t here sooner because no one wanted to make the pull request it is just dumb.
- chrsig 5y agoif someone's off on some tangent implementing a major feature without coordinating with the project maintainers and it subsequently gets rejected because it doesn't fit the constraints that they've stated for the feature...that's on them. the go project is pretty upfront with how they go about deciding what will/wont get into the project, what process to follow, etc. Posing it as "why doesn't go have generics" is bound to be reductionist, because it's too coarse of a question, and any real implementation winds up having a lot of nuance. the question winds up just sounding entitled and petulant though, so if someone can't be bothered to ask a well informed question about why go doesn't have generics yet, the best answer really is "because it hasn't been added.", tautological as it may be.
- lifthrasiir 5y agoIt was commonly stated (or claimed) that they didn't know how to add generics without sacrificing both compilation time and runtime performance [1]. To my knowledge they ultimately didn't choose a particular implementation strategy and instead chose a design that allows multiple strategies as needed. [1] https://research.swtch.com/generic https://research.swtch.com/generic
- wwarner 5y agoIt also seemed like the original intent was to support generics and metaprogramming through code generation and AST manipulation, the argument being that code generation and AST manipulation are the most general way to build complexity and specialization from a simple set of primitives. I personally don't think that generics and generation are mutually exclusive, but if they were, I'd side with retaining simplicity over the new feature.