News for hackers. Stuff that matters.
Re:Type erasure and reification by slavapestov on Wednesday December 05, 2018 @12:31PM (#18610405)
> Reification also comes at a cost: performance

On the contrary, reified generics give the implementation more leeway with representation choices which can help with performance. In Java for instance a `List<Integer>` is stored as an array of boxed Integer objects, without easily being able to store the values inline.

Re:Type erasure and reification by bunderbunder on Wednesday December 05, 2018 @12:43PM (#18610532)
That can be done even more easily with properly erased generics.

This is another of those unfortunate implications of Java's having disappeared into this ugly chasm between static and dynamic typing. It doesn't fully erase types, so you can't do like C++ or Haskell do and just generate a completely different type, because it wouldn't be compatible with any functions that work with the generic type. At least, not without breaking backward compatibility, which was the whole point of doing type erased generics in the first place.

Re:Type erasure and reification by slavapestov on Wednesday December 05, 2018 @10:32PM (#18615140)
> This is another of those unfortunate implications of Java's having disappeared into this ugly chasm between static and dynamic typing. It doesn't fully erase types, so you can't do like C++ or Haskell do and just generate a completely different type, because it wouldn't be compatible with any functions that work with the generic type.

Full monomorphisation is not compatible with separate compilation though.

Re:Type erasure and reification by dtech on Wednesday December 05, 2018 @01:10PM (#18610817)
I'm curious, what is not "proper" about Java's erased generics?

Reified types also bring other advantages, e.g. runtime reflection can be useful and can enable meta-programming and allows check binary compatibility of dynamic linking.

So gives that you want a language with reified types, losing that reification with generics creates awkward cases in the languages and prevents possibility for optimization.

Re:Type erasure and reification by bunderbunder on Wednesday December 05, 2018 @01:28PM (#18610997)
They're not erased all the way, they're only erased down into the root type for all objects. So you've still got some type information left (namely, that it's an Object), and any types that are not Objects are officially banned from the generics system.

Hence the need to dress them up as washerwomen and sneak them in through the service entrance.

Re:Type erasure and reification by whateveracct on Wednesday December 05, 2018 @08:45PM (#18614672)
Haskell has erased generics and unboxing for days.
Re:Type erasure and reification by dllthomas on Thursday December 06, 2018 @03:27PM (#18621851)
> ... for days.

Is that an estimate of Haskell compilation time?

Re:Type erasure and reification by whateveracct on Thursday December 06, 2018 @03:35PM (#18621931)
My professional experience has been that Haskell compile times are great tyvm :)
Re:Type erasure and reification by dllthomas on Thursday December 06, 2018 @03:49PM (#18622066)
"Days" is obviously hyperbole, but I typed that while waiting for a Haskell build and I'm still waiting on that same build. Granted that I'm rebuilding a whole lot more of the world than typical, but build times are definitely one of my few complaints about working in Haskell (though it's been improving).