Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



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


Casting (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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: