I'm curious which statically-typed languages have no generics support (and to a lesser extent which languages historically did not have generics), and how they deal with it.
Do users just cast all over the place? Is there some special sauce for basic collections, like lists and dictionaries, that allow those types to be generic?
Why do these languages not have generics? Is it to avoid potential complexity or other reasons?
C—and historical C++, before it was called C++—requires you to either manually expand "generic" types into non-generics (i.e. the C preprocessor macro equivalent of C++ templates) or escape the type system (i.e. void pointers).
However, arrays (lists) are treated as composite types rather than a single type. You can have an array of shorts, for example, but you could not treat it the same as an array of chars or even of longs.
This isn't a really big problem in C, though inconvenient at times. It does represent a trade-off from 40 years ago, to put it in context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With