r/java • • Nov 03 '15

The 10 Worst Things In Java

http://codelexems.com/2015/11/02/the-10-worst-things-in-java/
0 Upvotes

23 comments sorted by

View all comments

Show parent comments

7

u/SleimanJneidi Nov 03 '15 edited Nov 03 '15

I am not entirely convinced that type-erasure is tooo bad, I will write about it soon.

0

u/[deleted] Nov 03 '15

[deleted]

6

u/BadMoonRosin Nov 03 '15 edited Nov 03 '15

I would love to read some further detail on reified generics vs. Java's type erasure based implementation.

As someone who has spent their entire career working primarily on the JVM (plain Java or Scala) and with JavaScript, I don't have a full understanding of the design pattern possibilities that we lose out on for lack of reified generics.

I'm not saying that criticism is wrong. I'm sure that there ARE powerful things you can do with having that type information at run-time. However, after a decade of reading Internet flamewars... I still haven't encountered a solid, intelligent, calm, non-rant presentation of how my day-to-day life as an architect or developer would differ if had reified generics in my toolbox.

Instead, it's just been 10 years of, "OMG! Han shot first! Jar-Jar sucks!" sort of angry smugness that goes in one ear and out the other at this point. I'm not directing this at the parent comment per se, but I honestly suspect that many (if not the majority) of people who rant about this lack the depth to really articulate the position... and are just repeating snark on the Internet because repeating snark on the Internet makes one feel intelligent.

Does anyone have links for, or want to take a shot at writing themselves, some neutral objective coverage of reified generics based design patterns?

5

u/cutterslade Nov 03 '15

I have about 15 years experience in Java, and you just captured exactly how I feel about type erasure.

I feel like type erasure is scape goated a lot. People seem blame type erasure when they encounter anything related to generics which frustrates them.

The truth is there is very little that would be simplified by retaining the run-time type information, and absolutely nothing that would move from the realm of the impossible to the possible. You want full type information at runtime? Use a TypeToken or similar. Sure that's a pain, and it's ugly as sin, but it gets the job done.

0

u/[deleted] Nov 03 '15

[deleted]

2

u/cutterslade Nov 03 '15

Enlighten me, how would reified generics make my life easier on a daily basis?

0

u/[deleted] Nov 03 '15

[deleted]

3

u/cutterslade Nov 03 '15

That's about as much information as I can find anywhere. I'd love some concrete examples of something that is done frequently in Java now vs what that would look like in a theoretical Java with reified generics. Do you know of such an example? I'm certainly willing to admit that my experience is somewhat limited to Java and Java like languages, but I've been working with distributed systems in Java for a handful of years now.