3 ms·
Rust does have generics. There's little value in constructing a distinction between "templates", "generics" and "parametric polymorphism", at least not for the
by dbaupp 8y ago
Rust does have generics. There's little value in constructing a distinction between "templates", "generics" and "parametric polymorphism", at least not for the parent comment, which was likely intended to mean "Rust has a well designed system for working with 'unknown' types". (Also, maybe you could be specific about what you think the difference is.)
Go also doesn't have subclasses, so that doesn't seem relevant.
- mcguire 8y agoThey're the same thing: "Generics" is a term from software engineering, describing how the concept is typically used. "Parametric polymorphism" is a description from a type theoretic standpoint. "Templates" are an implementation strategy.
- dbaupp 8y agoI understand what these words mean... At least, I understand the variety of meanings they have: they're not always used to mean the same thing. For instance, people will rightly say that Java doesn't strictly have parametric polymorphism because of dynamic type casts, but they will say it has generics. Other people might draw a distinction between generics and templates, with the former being constrained (with type classes or similar) and the latter being macro-like. However, I don't think these are actually particularly relevant to the original comment (and, I really think that Rust probably satisfies "generics" more than "parametric polymorphism", because one can also do generic casts).