News for hackers. Stuff that matters.
Re:The Java type system is broken by MaxBarraclough on Thursday July 19, 2018 @11:41AM (#17567345)
> If Java had generics in the beginning, it would look a lot different and the type system would be more powerful and safe.

And conceivably a good deal faster, too. My understanding is that the JVM is required to constantly perform runtime type checks.

Re:The Java type system is broken by icedchai on Thursday July 19, 2018 @03:27PM (#17569506)
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.

Re:The Java type system is broken by mcculley on Thursday July 19, 2018 @04:10PM (#17569817)
Those casts are still there. The compiler puts them in and the JVM has to execute them.
Re:The Java type system is broken by icedchai on Thursday July 19, 2018 @04:15PM (#17569843)
Yes. And my point is they'd be there anyway, with or without generics. It's not "generics" making the JVM any slower.
Re:The Java type system is broken by mcculley on Thursday July 19, 2018 @04:26PM (#17569932)
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.

Re:The Java type system is broken by monocasa on Thursday July 19, 2018 @12:44PM (#17568068)
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).
Re:The Java type system is broken by icedchai on Thursday July 19, 2018 @03:28PM (#17569511)
Without generics, the developer would have to cast from Object anyway.
Re:The Java type system is broken by lmm on Thursday July 19, 2018 @03:48PM (#17569662)
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.
Re:The Java type system is broken by leshow on Thursday July 19, 2018 @03:00PM (#17569323)
and pointer chasing too right? unless the runtime can optimize, every generic sits behind a pointer.