4 ms·
> Isn't it stil mostly Java and C++? That's what I hear all the time here. Go's type system is much weaker and less expressive than either Java's or C++'s. C++
by acchow 5y ago
> Isn't it stil mostly Java and C++? That's what I hear all the time here.
Go's type system is much weaker and less expressive than either Java's or C++'s. C++ in particular has parametric polymorphism, type constructors, and dependent types. Go has none of those.
- EdwardDiego 5y agoQuestion from genuine interest, how is Go's type system weaker than Java? Is it just the (until recently) missing generics. I know that casting to interface{} is the equivalent of casting to Object, but Go 1.18 should hopefully avoid most of that. Just wondering what else you're thinking of, asking as someone who knows Java well and Go okay.
- erik_seaberg 5y agoEverything is mutable. Builtin operators like assignment and equality are hardcoded and may behave badly for user-defined types. It doesn’t have subtypes; you can slice to an embedded value but can’t get from there back to the containing struct or its methods. It doesn’t have generic covariance and contravariance; you can’t decide whether a []Animal or a []Bulldog is acceptable in place of a []Dog.