Quoto ancora uno spezzone dell'intervista ad Anders
Hejlsberg che conferma quanto avevo riportato in un mio vecchio post e nel successivo articolo uscito su CP di
Novembre:
You wouldn't get any efficiency from using generics with primitive types. When
you take things out of a list of a certain type, for example, the compiler needs
to insert type casts. Nonetheless, they still incur the overhead that they
always did at runtime, so you don't get any execution efficiencies from using
generics in J2EE.
The other thing is more subtle, but more important. When you
erase type information at compile time, you don't have faithful reflection at
runtime. So, you wind up with fewer features available. The industry is relying
more and more on dynamic code generation, so it is more important that we have
faithful type representations at runtime. In .NET, you can go to any object at
runtime and ask it what its type is. For example, with generics in .NET 2.0, I
can actually go ahead and understand that I am holding a list of integers. In
Java's "erased world," I only know that I have a list - I have
no idea what is in the list.
Fonte: .NET Developer's
Journal
powered by IMHO 1.2