An Update on Go and Generics in 2019
medium.com
medium.com
I worked on 3 projects in Go and in 2 of those generics would have been very useful.
I ended up copy pasting a bunch of functions and changing their types (interfaces would have been even worse in those cases).
There is a library doing that automatically, like c++ templating but worse since it is not part of the compiler.
Combined with anti-features like null pointers, rather stupid and overly verbose error handling and awful dependency management, it makes for a language which often feels hindered by shortsighted oversimplification.
I kind of like the simplicity of Go. But they lobbed too many things over board without having proper replacements. And repeated dumb stuff from other languages which should be no part of any modern language (Billion Dollar Mistake ect.)
IIRC it is along those lines :
You could define a `Lesser` interface with a method `Less(Lesser) bool`, and implement this interface on what you want to sort, but then you would have no way to assert at compile time that x and y are of the same type in `x.Less(y)`.
As I understand them, contracts allow you to assert things like this.