Question: But do you seriously don't know the use cases for generics?

Asked By
Asked At
2017-07-26 20:46:38

Found 15 possible answers.

User Answered At Possible Answer
jslovato 2017-07-26 20:50:22 When you can't afford the namebrand?
egon 2017-07-26 20:50:49 @zerkms the problem is not about knowing the use cases, it's about knowing the priority of those use cases in Go community and problems that Go programmers face in practice. rsc, dlsniper, ian and others are well aware of tons of different use-cases, the question is about priority and importance of them.
dlsniper 2017-07-26 20:52:29 ^
zerkms 2017-07-26 20:52:32 > tons of different use-cases it's weird to see though how the community is hostile to even the idea of introducing those
dlsniper 2017-07-26 20:52:47 nobody is hostile to introduce generics Ian Lance Taylor tried 4 different approaches to them
zerkms 2017-07-26 20:53:08 even me, who does not develop in Go seen tons of comments in blogs asking to NOT consider implementing them
mvdan 2017-07-26 20:53:31 some people think they should exist, some people think they shouldn't - neither is hostility
dlsniper 2017-07-26 20:53:32 if hostility would be a problem, then nobody would even bother having this discussion
egon 2017-07-26 20:53:35 The problem is that most of the "use-case" examples that people show start with "Let's say we have a class Animal and then we want to parameterize with Legs..."
zerkms 2017-07-26 20:54:01 > some people think they shouldn't this makes no sense
egon 2017-07-26 20:54:02 We need real world examples from production code bases.
dlsniper 2017-07-26 20:54:03 the problem is that there are "use-cases" and use-cases. see what @egon is about to say :slightly_smiling_face: for me an example of generics use-case would be sync.Map
zerkms 2017-07-26 20:56:00 I'd say the good part of what is currently implemented with interface{} could also be avoided with generics
egon 2017-07-26 20:57:01 And no "I wanted to have a set type but wasn't able to implement one" is not sufficient... Saying that "I wanted to implement a parallel search over regular expressions for gene pattern discovery and faced a problem where I wasn't able to express alphabet size differences causing more memory allocations due to having to use []byte instead of a fixed size letter." is much better.
dlsniper 2017-07-26 20:57:25 because it would provide type-safety at compile time instead of runtime and would simplify the usage and increase the speed of execution and lower memory pressure on the app unfortunately I don't have any numbers to back the speed and memory statements but I have the experience of using it, which accounts for the first two, and I have the experience of typing a bunch of type assertions for it

Related Questions