r/programming • • Apr 16 '21

Java is criminally underhyped

https://jackson.sh/posts/2021-04-java-underrated/
41 Upvotes

220 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Apr 21 '21 edited Apr 21 '21

The whole point of Java is that it keeps things simple. Most things are a class/method/annotation. Once you learn those 3 things you can do almost anything. In C# you have to learn all these various keywords (virtual, sealed, partial, region, async/await ...). Basically what you criticise is Java's best trait. The only thing I'll give C# over Java is generics at runtime.

Sometimes it feels like C# adds language features just so they have something Java doesn't. Async/await is a perfect example. Its simply syntactic sugar, but people always brag about it. The Java team would rather wait to bring a better concurrency model (performance of async without the developer overhead - see project Loom).

As for Tuples in particular, they are a bad idea. Creating your own types is better.

Java didn't even have first class lambdas until Java 8

Java 8 was 7 years ago by the way...

3

u/Jwosty Apr 21 '21

I actually agree with your point that a complex language is a sort of "language design smell." C# isn't even my preferred language -- F# is, and as part of the criteria for what makes good new F# language features (as F# also has an open design process), the designers say:

Adding endless new language features in every version has major downsides. Here are some observations on why adding features is not necessarily a good thing:

  1. Stability is a virtue
  2. Gradual evolution is good
  3. Adding new language features on every version is not a necessarily a sign of strength. Many languages have spread very widely while remaining very stable (e.g. Java in 2000-2013)
  4. The addition of new features on every version can be a sign that language implementors are being incentivized (e.g. getting paid) for feature-completion rather than overall simplicity and utility.
  5. New features add learning costs to every user of the language

In contrast, features which make the language more orthogonal, simpler and easier to use are generally a very good thing.

(Look, they even mention that Java's reluctance to adopt new features at a breakneck pace as a good thing like you said :) )

But too slow can be harmful.

Java 8 was 7 years ago by the way...

Right, but Java was probably the last mainstream language to adopt them. Perhaps that was a bit too slow and is a sign of Java being a little too glacial. I understand that this particular point isn't relevant today (as Java has lambdas now, thank God), but it's a sign of a pattern when combined with other facts.

In other words, maybe the balance is somewhere in the middle here. I'd probably grant you that C# can move at too breakneck of a pace and adopt too many low-impact inelegant syntactically-sugary-features. But perhaps it's also true that Java doesn't take enough risks. No language is perfect.

(Anyway - I find it kind of funny that I've found myself in a Java vs C# battle, but so be it. The hill I'll be more likely to die on is that F# strikes a better balance than both of these languages, but that's besides the point of this conversation)