Re:Java Generics FAQs
by seanmcdirmid on Friday April 17, 2015 @03:47AM
(#9392757)
> There are two main ways to implement them that I know of--the Java style, with type erasure, and the C++ style, where you essentially generate code for each instantiation--both have significant drawbacks.
There is also C#/.NET style, which maintains the type system aspect as Java and the run-time reification and efficiency of C++.
> OTOH, if you don't have generics, you either just use concrete types or you essentially do type erasure yourself, explicitly (eg with interface{} in Go or void* in C). It costs you a few casts and maybe some code duplication.
Exactly like Java pre-generics, I remember the JDK 1.0.2/1.1 days also.
> I think erring on the side of simplicity and avoiding generics altogether is more than worth it.
They don't need it day one (neither Java or C# had it in 1.0), but they'll eventually need to add something for generic programming.
There is also C#/.NET style, which maintains the type system aspect as Java and the run-time reification and efficiency of C++.
> OTOH, if you don't have generics, you either just use concrete types or you essentially do type erasure yourself, explicitly (eg with interface{} in Go or void* in C). It costs you a few casts and maybe some code duplication.
Exactly like Java pre-generics, I remember the JDK 1.0.2/1.1 days also.
> I think erring on the side of simplicity and avoiding generics altogether is more than worth it.
They don't need it day one (neither Java or C# had it in 1.0), but they'll eventually need to add something for generic programming.