Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the main differences between C# and Java? [duplicate]

Tags:

java

c#

Possible Duplicate:
What are major differences between C# and Java?

I believe it was Eric Sink that said "C# is Java done right". I am pretty familiar with Java, and thought I could try to learn some C#.

As I understand it, these two OO-languages are very similar, so what are the actual differences (if any)?

like image 800
Lars Andren Avatar asked Apr 13 '10 04:04

Lars Andren


1 Answers

Having used both extensively for various projects both commercial and hobby, I prefer the expansive open source community around Java, but the tools and (these days) quicker language advancement around C#.

Pro C#

Java got a 5 year head start on C#, during which it tried a bunch of groundbreaking stuff and gave C# some mistakes to learn from and some best practices to adopt. You can viscerally feel the difference that this makes in the class library design, in the way generics are implemented, and just in general polish.

When you add to this the fact that C# introduces a new crop of powerful, carefully chosen, and well-integrated language features every couple of years (LINQ, closures, type inference, the dynamic variable type, generic support for co- and contra-variance, etc.), it really tends to be a joy to use.

I'm actually surprised to find myself saying this, but you can count on Microsoft to bring in some of the best features from languages as diverse as Haskell, JavaScript, and Python directly into C#. All signs point to this trend continuing.

Pro Java

Java, on the other hand, had a 5 year head start (plus even more if you consider how long it has taken Microsoft to begin to come around to doing things more openly) on building a community around it. This gives rise to the fact that NUnit is a port of JUnit, NHibernate is a port of Hibernate, and in general N* is a port of J*.

You usually end up getting very similar sets of incredible tools from each language's respective community, but a lot of stuff existed (and thus matured) in Java before it existed for .Net.

Summary

Both are worth knowing, and there are tons of things to learn from both. They both have solid communities with slightly different takes on the world. I recommend knowing both and watching them closely going in to the future.

like image 114
sblom Avatar answered Oct 05 '22 23:10

sblom