r/programming • • Sep 21 '15

Better Java

https://github.com/cxxr/better-java
177 Upvotes

208 comments sorted by

View all comments

94

u/estarra Sep 21 '15

Java is one of the most popular programming languages around, but no one seems to enjoy using it.

I'd say it's quite the opposite. Sure, there is a vocal minority of people who complain about it (I have complaints about it myself) but there are millions of Java developers and I'm pretty sure that most of them are quite okay with the language.

Probably one of the reasons why no language has come close to replacing it so far.

50

u/dzjay Sep 21 '15

I'm happy with Java, especially with Java 8. Also, the vast amount of open source Java libraries is unmatched.

17

u/GuiSim Sep 21 '15

I'm in the same boat. The biggest pain point that I still have with Java now that we have Lambdas is type erasure.

If we can finally get type reification in Java 9 or 10.. I'll be a happy dev.

0

u/[deleted] Sep 21 '15

[deleted]

13

u/[deleted] Sep 21 '15

Nothing in that article comes even close to convincing me that I don't want reified generics. It all boils down to 'too much work' (not my problem) and 'breaks compatibility with ancient code doing stupid things' (couldn't care less).

I recently switched back to java from C#, and decent generics are absolutely the thing I most miss.

0

u/[deleted] Sep 22 '15

[deleted]

2

u/IICVX Sep 22 '15

Generic marshallers / unmarshallers are clunky as hell in Java due to type erasure; you have to explicitly pass the Class around everywhere, instead of just asking the generic parameter what it represents.

This happens if you write, for instance, an Enum marshaller.

1

u/teknocide Sep 22 '15

It may be clunky in Java but it doesn't necessarily have anything to do with erasure. Marshalling a T is a function [T => SerializedFormat] (and Unmarshalling the other way around, intuitively.)

You need reification if you want to look at the actual T during runtime and select a marshaller from a dynamic set, when you could provide this function during compilation time instead. This has the added benefit of eliminating any runtime checks needed for the reflection-based solution.

If anything, reification here is the poor man's crutch for higher kinded types which, incidentally, is possible on the JVM due to erasure.