Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

closed as primarily opinion-based by rwong, MichaelT, Bart van Ingen Schenau, GlenH7, gnat Jul 3 at 17:19

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
C# doesn't have the Java "enum values are classes"-feature. –  Patrick Jul 3 at 9:56
2  
@Patrick - Is that a feature - or an implementation detail? –  Pete Jul 3 at 9:56
8  
Biased answer: Because the C# design team know what they're doing. More reasonable answer: C# was designed with the knowledge of Java's failures and without the dogmatic "only pure OO" (that they didn't even quite hit). Half of those features were bulk-imported from Lisp and Haskell, two languages Java steadfastly refused to be inspired by until java 8, and the others are sanity improvements made blindingly obvious by Java's lack of them. –  Phoshi Jul 3 at 9:57
3  
Because C# came later and was initially a blatant rip-off of Java, and then had the opportunity to add everything that turned out to be worthwhile in addition, while Java was hampered by very strict backward compatibility goals. –  Kilian Foth Jul 3 at 10:02
2  
@KilianFoth: Actually, C# was initially a batant rip-off of Delphi, rewritten to look like Java. Microsoft even poached the Delphi project architect away from Borland to create it. –  Mason Wheeler Jul 3 at 15:42

2 Answers 2

up vote 12 down vote accepted

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.

share|improve this answer
4  
I'm not sure I agree with this. I mean it's all true, but I suspect that the reason has more to do with the politics around the collapse of Sun. Java basically had 5+ years or so where there was no organization/leadership - so there were no new features. –  Telastyn Jul 3 at 11:45
4  
C# 1 had value types. Something that Java will never have. So not just a "blatant rip-off". –  Den Jul 3 at 13:15
1  
@Telastyn -- I think that is the single most important reason here. Especially when you add "and then you get acquired by oracle" to the end of the Sun collapse. –  Wyatt Barnett Jul 3 at 13:18
6  
Agree with @Den. I think the biggest reason for C# developing faster (and in the right direction) is the leadership of Anders Hejlsberg. He and his team have added the best features from other languages, and managed to integrate them seamlessly into C#. The result is that C# has very neat language features without feeling cluttered or messy. –  David Kirkland Jul 3 at 14:12
1  
@WesleyWiser - upgraded to "might have in future". –  Den Jul 7 at 21:18

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.

share|improve this answer
    
The nine lines needed for a simple property definition (declaration + get/set + white space) add up quickly to more than "a few". –  kevin cline Jul 3 at 16:13
    
@kevincline and I also document properly both setters and getters. But in the end, even if I am not using my IDE automatic code generation for the accessor, I am not using any noticeable amount of time with these, when you factor in the time spent in business logic, testing, code design (in fact I am mostly thinking about these even when typing the accessors). So, while nice, it is not something that makes a great difference in the end... –  SJuan76 Jul 3 at 16:26
    
It's not the time to write them. It's the time to read and ignore them, over and over and over and over again, while you are on your way to the interesting parts. –  kevin cline Jul 3 at 21:04
    
@kevincline I agree, it's abiut readability and the code being clean. This is why I value things like Events, which are just a built-in Observer pattern, but make things much cleaner thab if you had to write these yourself –  Aviv Cohn Jul 6 at 11:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.