3 ms·
I just know that generics are helpful. Not just a convenience, but genuinely helpful. And it gives a kind of help that can't easily be replaced by a new library
by sdegutis 12y ago
I just know that generics are helpful. Not just a convenience, but genuinely helpful. And it gives a kind of help that can't easily be replaced by a new library or third party tools. Which, to me, makes generics a very welcome language addition. You could very well code big and small projects without them (and I have too). But that doesn't negate their utility.
- stcredzero 12y agoNot just a convenience, but genuinely helpful. Specifically, how? EDIT: Surprisingly, programmers do a lot of this "just knowing." You'd think that a supposedly quantifiable field would have more, quantification. Going by "guts" is particularly bad in big enterprises, where decisions are often more about politics than about quantifiable results.
- Someone 12y agoI can guess what he hints at. If you don't have generics, you either copy-paste-replace common data structures, or you implement them for the equivalent of void . The former means more code. That can be hidden out of view, but it means more work when fixing bugs in that code, introduces subtle bugs when one forgets to apply a bug fix to a 'copy', and slows down compiles. The latter means adding casts to your code that make it harder to read and (more code is buggier code) also runs the risk of introducing bugs. The two-and-halfth option is to use some preprocessor to generate code variants for you. IMO, that is just a bad implementation of generics. Yes, that is not quantified, but I think it covers the how* part.
- AlisdairO 12y agoCasting (for example) is a pain, but to me the best aspect of generics is the documentation they provide of the types involved with a given piece of code.