Question

Please note that this isn't meant to be a Java vs. C# argument. I'm a Java programmer with no C# experience, asking just out of curiosity.

I did some reading on C#, and it seems it has much more features than Java. A number of examples:

  • Type inference.
  • dynamic keyword.
  • Delegates.
  • Optional parameters.
  • Lambda and LINQ (I actually have no idea what these are).
  • Properties.

However Java doesn't really feature anything that C# doesn't have.

My question is: why does C# have much more native features than Java? And why didn't Java add some of these throughout the years, for example Properties or type inference? Do the Java language designers take a more simplistic approach? What is the reason for this?

Was it helpful?

Solution

Several reasons:

  1. C# came later than Java; version 1 was a blatant rip-off of Java 1.4, so it pretty much had everything Java had at that point.
  2. But then C# developed much faster than Java, because it was an exciting new platform (and had an utterly brilliant driver in Anders Hejlsberg, the father of Turbo Pascal). That allowed them to avoid all the mistakes in Java that had become obvious, while adding everything that Java practitioners wished they had.
  3. Meanwhile, Java was hampered by very strict backward compatibility goals and by a somewhat slower pace of development, partly because it tried desperately to gain a reputation for being the standard, enterprisey, reliable, non-surprising solution for the 95% of non-genius programmers. At this they succeeded, perhaps a bit too well.

The result is that Java now has a bit of a feature gap. It does have huge plans for the future, but as usual with this sort of thing everything takes a bit longer than planned.

OTHER TIPS

I would add to Kilian's answer that one big difference between Java and C# is that C# designers control not only the language, but also the standard IDE.

Adding something like extension methods and partial classes could be a nightmare in development/control versioning if the IDEs would not properly support it.

Since you are expected to be able to compile Java with your platform of choice (Eclipse, Netbeans, vi + Ant), adding features that break the code (and using these to develop additional extensions like LINQ) is way more complicated than just saying "since IntelliSense will deal with these cases, we need not to worry".

Additionally, sometimes it is worth noting the value of the features instead of its number. For instance, automatic properties are nice and I certainly wish Java supported this, but in the end it only means that you have to write a few more lines of code in Java. Similarly, I find that calling "Events" a feature is somewhat of a misnomer, since they are little more than specially labelled delegates, and just a refined copy of the Observer pattern already used by Java (then again, in Java it needs more explicit coding)

Don't get me wrong, I think C# has introduced several noteworthy innovations, and I wish that someday Oracle big bosses will wake up and launch a true "Java 2" to include some of these, but the gap is not as obvious as your question points.

Licensed under: CC-BY-SA with attribution
scroll top