Good deal faster? I seriously doubt it. My understanding are generics are purely a compile time feature and does not effect run time.
I remember Java before generics: tons of casting from Object. The compiler is doing the same thing.
Those casts are still there. The compiler puts them in and the JVM has to execute them.
Yes. And my point is they'd be there anyway, with or without generics. It's not "generics" making the JVM any slower.
If the types were reified, the compiler and the JVM would know what type was there. No cast would be needed.
Re:The Java type system is broken
by MaxBarraclough on Friday July 20, 2018 @04:39AM
(#17573390)
> they'd be there anyway
No. That's the point.
Yeah, it either has to cast from Object all the time, or spend JIT compiler time and memory figuring out if it can elide those checks (probably with exception code for when it guesses wrong).
Without generics, the developer would have to cast from Object anyway.
The point is that if Java had had generics in the beginning, they could (perhaps) have been integrated into the language in a way that obviated those casts entirely.
And conceivably a good deal faster, too. My understanding is that the JVM is required to constantly perform runtime type checks.