3 ms·
Increases compared to what? If you don't use generics and write the code for each type manually, you'll end up with exactly the same thing.
by xigoi 5y ago
Increases compared to what? If you don't use generics and write the code for each type manually, you'll end up with exactly the same thing.
- pshc 5y agoIncreased compile time compared to doing polymorphism with an extra layer of indirection, I’m guessing
- zwieback 5y agoI often wonder about that - if I was going to write by hand I might end up extracting a simple interface, do some type coercion/promotion or some other trick to reduce the number of functions I need to write. I read about how .Net does Generics at the VM level and was very impressed, a good compromise between C++ "macro expansion" and Java "type erasure", both of which seem extreme. At the end of the day, though, when generics are present I stop worrying and just use List<int>, List<float>, List<char>, etc. without a second thought. The compiler, VM or runtime can deal with it although I might get punished in some way.