r/learnjava • • Jun 21 '21

Why learn Java when there's C#?

I am genuinely curious, as it seems C# has superseded Java in many regards. The only reason I can think of using Java is backward compatibility.

EDIT: To clarify, the main selling point of Java was cross-platform, but nowadays most frameworks and toolsets are to some degree cross-platform, including .NET Core, which is the new main framework of C#.

0 Upvotes

36 comments sorted by

View all comments

4

u/berry120 Jun 21 '21

Some good takes already, but here's another:

A decade or so ago, I'd have agreed with you. But C# has, IMHO, fallen to the same trap as C++. It's a decent enough language, but near unbounded feature expansion over many, many years has led to very few people understanding the language in its entirety - most people only ever use a subset of it. That creates technical problems with non obvious behaviour, and business problems with hiring people that understand the specific parts of C# that you happen to be actively using.

For better or worse, Java has been much, much slower on the uptake of new language features - it's only seen real significant changes in two versions, perhaps 3. While that's been frustrating at times, and means we lose some of the nice syntactic sugar of C#, it also means most senior Java devs can near enough fully understand the language. That means, on balance, there's fewer gotchas, and it's easier to hire decent people with a good experience of the language.

1

u/kres0345 Jun 21 '21

As a student I don't know how bad this is, but I can certainly see it being a problem. Some things, like the query syntax, are unnecessary additions and are only contributing to a more divided language.

3

u/berry120 Jun 21 '21

It's much more of a problem in a business environment than it is a personal one. For your own side projects, use whatever, embrace all the funky language features, knock yourself out, have fun.

For business use - companies generally want a dependable feature set in a language they know they can hire for easily. Java does that well, and while it's certainly not as modern or feature rich as some other languages, that (plus other reasons of course) often make it a very strong contender when deciding what language to base a greenfield project on.