r/learnjava • u/kres0345 • 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
-2
u/kres0345 Jun 21 '21
this is the first thing I could find, https://softwareengineering.stackexchange.com/a/125718/290637
I am aware of that it only addresses the things C# beats Java in.
Instead of a lot of noise (EJB, private static class implementations, etc) you get elegant and friendly native constructs such as Properties and Events.
I am aware that it only addresses the things C# beats Java in.generics), and you can perform reflection on them.
It supports native resource-management idioms (the using statement). Java 7 is also going to support this, but C# has had it for a way longer time.
It doesn't have checked exceptions :) (debatable whether this is good or bad)
It's deeply integrated with Windows, if that's what you want.
It has Lambdas and LINQ, therefore supporting a small amount of functional programming.
It allows for both generic covariance and contravariance explicitly.
It has dynamic variables, if you want them.
Better enumeration support, with the yield statement.
It allows you to define new value (or non-reference) types.
I've only used Java for app development since I like Android Studio more than Xamarin, but in the time I've used Java I keep finding myself looking for features that are present in C# but aren't in Java, like properties (much nicer than manual getter and setter methods), enums, the simple syntax of LINQ and generics.