Hacker News new | ask | show | jobs
by endtime 5811 days ago
Why does Generic Programming require static types?
3 comments

The 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

See also: http://en.wikipedia.org/wiki/Type_polymorphism#Parametric_po...

From 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.

Dynamic typing (ala Scheme or Python) gives you generic programming for free, but it's less efficient.