Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yet another language tries to bolt on generics after the fact and finds that doing so results in awkwardness. Note to language designers: if you are creating a general purpose language, you will eventually need to add generics. You can either do it right at the beginning, or else you have to bolt it on at the end. Rust gets kudos in this regard for having well designed generics from the beginning.


Kudos also to prior art, such as the ML family of languages, which Rust derived inspiration from :)


Rust has parametric polymorphism, not generics, and doesn't have subclasses. This makes it not quite the same thing.


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.


They'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.


I 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).





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: