10 ms·
Sorting using generics is faster and more ergonomic. That's why they are adding generic based sort to the standard library. https://pkg.go.dev/golang.org/x/exp
by IshKebab 2y ago
Sorting using generics is faster and more ergonomic. That's why they are adding generic based sort to the standard library.
https://pkg.go.dev/golang.org/x/exp/slices#Sort https://pkg.go.dev/golang.org/x/exp/slices#Sort
Sort on its own is maybe not the best example because it's relatively easy to work around, but those workarounds quickly break down. Write me a function that returns the keys of a map in order without using generics...
I'm not exactly sure what your second point is.
- cherry_tree 2y agoBut go isn’t a language without generics, so I don’t understand the criticism
- Capricorn2481 2y agoWell you were quoting a part that said "in a language without generics" and were questioning why that was bad, so that's what they responded to. But that used to be Go, and it got a lot of pushback when generics were introduced. It illustrates an issue people have where obviously good language features are rejected by a loud minority for seemingly no good reason.
- School-Cotton 2y agoYou were specifically asking about generics. If you wanted me to give an example of the usefulness of some other feature that Go refuses to add, I would. Yes, Go finally added generics (years too late). But the fact that so many people were opposed to them for so long illuminates something about Go culture that is still relevant.