5 ms·
Why does Generic Programming require static types?
by endtime 16y ago
Why does Generic Programming require static types?
- Robin_Message 16y agoFrom the OP's definition, it needs static types so it can be compiled efficiently. You can do it dynamically (e.g. Ruby) but you can't do it as fast in general. Additionally, generic programming is a computer science concept, and those types tend to prefer static-typing for safety reasons. They're probably not strictly necessary if you ignore efficiency.
- pohl 16y agoThe type-parametric functions are inherently a feature of a static-typing system...so I guess "by definition" would be the answer. At least that's what the wikipedia entry would lead me to believe. http://en.wikipedia.org/wiki/Generic_programming http://en.wikipedia.org/wiki/Generic_programming See also: http://en.wikipedia.org/wiki/Type_polymorphism#Parametric_polymorphism http://en.wikipedia.org/wiki/Type_polymorphism#Parametric_po...
- klipt 16y agoDynamic typing (ala Scheme or Python) gives you generic programming for free, but it's less efficient.