2 ms·
> Yes, the mindset of the people was certainly a key part of this, but another key part is that Go has interfaces, which are existential types, which are dual t
by masklinn 5y ago
> Yes, the mindset of the people was certainly a key part of this, but another key part is that Go has interfaces, which are existential types, which are dual to universal types (colloquially called generics).
The biggest reason was probably that it had bespoke generics for a bunch of core collections, significantly mitigating the need for userland generics.
Without the builtin generic slice, map, and channel, the issue would have been significantly less tenable on both efficiency and convenience fronts.
It's not like "we have interfaces and we still need generics" is a new thing.
- 4ad 5y agoThis argument is often repeated but doesn't make any sense. The value of generics is quantifications over types. In particular univeral quantification. "Generic" slices don't give you that, because the values are "generic", but there are no non-static type constructors. Go slices are "generic" only in the same sense than arrays in C are generic, or (if we go to the degenerate case) that a variable is "generic" because you can declare it with any type. I'm sorry, what? Go has existential quantification, something which C lacks. Go is very unusual that it started with existential types. Languages based on System Fω have universal quantification as a native operation and implement existential types as higher rank universals. The fact that Go had existentials from the beggining is not some technical nitpick, it is what gives it type-level expressive power over languages like C. Ignoring this in arguments about generics is missing the point completely.