I'm surprised by the complexity of Go's generic constraints, given the language's focus on simplicity. Things like the difference between "implementing" and "satisfying" a constraint [0], and exceptions around what a constraint can contain [1]:<p>> <i>A union (with more than one term) cannot contain the predeclared identifier comparable or interfaces that specify methods, or embed comparable or interfaces that specify methods.</i><p>Is this level of complexity unavoidable when implementing generics (in any language)? If not, could it have been avoided if Go's design had included generics from the start?<p>[0] <a href="https://stackoverflow.com/questions/77445861/whats-the-difference-between-types-implements-and-types-satisfies" rel="nofollow">https://stackoverflow.com/questions/77445861/whats-the-diffe...</a><p>[1] <a href="https://blog.merovius.de/posts/2024-01-05_constraining_complexity/" rel="nofollow">https://blog.merovius.de/posts/2024-01-05_constraining_compl...</a>
i have been writing Go exclusively for 5+ years and to this day i use generics only in a dedicated library that works with arrays(slices in Go world) and provides basic functionality like pop, push, shift, reverse, filter and so on.<p>Other than that, generics have not really solved an actual problem for me in the real world. Nice to have, but too mush fuss about nothing relevant.
I like in Go how the code looks like a execution graph, by avoiding smarts and just copying code, when you have an error in the log you can generally just follow it through the code as there is only one path to get there. In C# I would have mostly to debug to understand where did it came from<p>Not just because of the language, but of the simplify culture. Let's see how generics will change that