December 4, 2004
Generics Preview
Generics is the most profound of changes envisaged in Tiger. Greg Travis has this nice preview on it.
In summary Generics offer the following advantages as per Greg:
- Better compile-time type checking: With generics, the type casting is implicit in the instantiation you are using, and it’s done at compile-time. By using a particular instantiation, you are in essence saying that this Object is really going to be a String, and the compiler will verify whether this is consistent with everything else going on in the program.
- Convenience: Casting can be irritating, it also makes code harder to read, since it can turn a simple assignment (or parameter-pass) into a more complicated expression. With generics, casting just goes away.