IssueRaiser

One common case that I've encountered: There's no (good) way of going "this is a Comparable<Foo> and a Comparable<Bar>, but not a Compar...

One common case that I've encountered: There's no (good) way of going "this is a Comparable<Foo> and a Comparable<Bar>, but not a Comparable<Baz>" that's detectable at runtime. (Also true with other interfaces.) Especially for trait interfaces. There are also nasty cases where you end up crashing randomly somewhere else in your code at runtime because somewhere something passed a List<Foo> and it expected a List<Bar>, but somewhere in between the type information got lost. Ditto, I find myself wishing to be able to do instanceof T &#x2F; T[] (that's an array of T) annoyingly often. Look at the mess that is EnumMap for an illustration of why type erasure can be frustrating. The amount of reflection done at runtime for what should be (and is, if you write a non-generic implementation, or if you're using a language that's sane) purely compile-time work is... frustrating. (And while you're at it, the fact that you can even attempt to pass in a non-enum into EnumMap. I thought Java was supposed to try to push such errors into compile time?)

Posted by TheLoneWolfling on Apr 17, 2015, 3:52 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.7,000 issues0 comments

hackernews (Software)

One common case that I've encountered: There's no (good) way of going "this is a Comparable<Foo> and a Comparable<Bar>, but not a Compar...

TheLoneWolflingApr 17, 2015, 3:52 AM

One common case that I've encountered: There's no (good) way of going "this is a Comparable<Foo> and a Comparable<Bar>, but not a Comparable<Baz>" that's detectable at runtime. (Also true with other interfaces.) Especially for trait interfaces. There are also nasty cases where you end up crashing randomly somewhere else in your code at runtime because somewhere something passed a List<Foo> and it expected a List<Bar>, but somewhere in between the type information got lost. Ditto, I find myself wishing to be able to do instanceof T &#x2F; T[] (that's an array of T) annoyingly often. Look at the mess that is EnumMap for an illustration of why type erasure can be frustrating. The amount of reflection done at runtime for what should be (and is, if you write a non-generic implementation, or if you're using a language that's sane) purely compile-time work is... frustrating. (And while you're at it, the fact that you can even attempt to pass in a non-enum into EnumMap. I thought Java was supposed to try to push such errors into compile time?)

Comments (0)

No comments yet. Start the discussion.

Comment on this issue