News for hackers. Stuff that matters.
Re:Generics enabled by default in Go tip by 4ad on Saturday August 21, 2021 @08:53AM (#28256596)
There are two meanings of "type erasure". One concerns the user, the other the compiler writer.

When most users people ask about type erasure, they ask whether types are erased when compiling the reflection information for polymorphic values (like Java does). Go doesn't have polymorphic values, so the question doesn't apply.

Type erasure means something more general than that to compiler people. Type erasure refers to whether you can compile code while erasing its type, and it's generally a useful property. In general statically-typed programming languages are implemented with type erasure, while dynamically-typed languages are not. Of course, since Go has reflection, it can't do type erasure. Interfaces also conflict with type erasure somewhat, though as expected, during the code generation types are erased as much as possible.

As a comparison, Rust does type erasure fully.

Re:Generics enabled by default in Go tip by iso8859-1 on Saturday August 21, 2021 @01:04PM (#28258586)
So Haskell has type erasure only for data types that do not derive Typeable?
Re:Generics enabled by default in Go tip by tome on Saturday August 21, 2021 @02:07PM (#28259141)
No, because all types have a Typeable instance! Haskell has type erasure, and then using Typeable adds the type information back exactly where it is needed.