3 ms·
No, Java generics are basically syntactic sugar over casts, which is why types are erased at runtime when you're trying to debug. Performance also isn't as good
by HideousKojima 3y ago
No, Java generics are basically syntactic sugar over casts, which is why types are erased at runtime when you're trying to debug. Performance also isn't as good as for C# generics since the Java approach limits optimizations.
- downWidOutaFite 3y agoThat's a minor implementation detail that devs almost never have to think about.
- jimbob45 3y agoYou'll run into it with generic arrays[0] in Java which are reasonably common. [0]https://www.baeldung.com/java-generic-array https://www.baeldung.com/java-generic-array
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- sgift 3y agoAs someone who works with Java all the time I'm the first to admit that something like TypeToken in GSON or comparable things in other libraries is not the greatest of things. I've also more than once wished I could to if(xy instanceof List<Something>), which you cannot do in Java. Can you work around it? Sure. Do I understand why Java has it? Yes. But "minor" .. no, it's not so minor in my experience.
- kriiuuu 3y agoHaskell also has type erasure. It’s an implementation detail, or are you saying that Haskell does not have proper generics?
- HideousKojima 3y agoI don't know the specifics of Haskell's implementation but if it's mostly the same as Java's then yeah?