6

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)?

5
  • 13
    C# is Java done right. Commented Apr 13, 2010 at 4:20
  • Plentiful ... To answer your first question, If you know Java you can fairly trivially pick up C#. To answer your main question, I suggest you do your own research. Commented Apr 13, 2010 at 4:21
  • 2
    I love the parting "(if any)" Commented Apr 13, 2010 at 4:22
  • I'm going to have to agree with BlueRaja, just because err... I don't know Java xD... But to be honest, the reason why I do like c# is because its... Err... TBH I don't have a reason. I lose, you win. Commented Apr 13, 2010 at 4:23
  • @Michael: The duplicate question had a very exhaustive summary of very detailed programming differences, thanks for posting it. Commented Apr 13, 2010 at 4:59

4 Answers 4

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your extensive answer sblom, it is a very nice summary of several aspects.
3

Have a look at

Comparison of Java and C Sharp

Java vs C#/.NET

1 Comment

Thanks! Those links were very helpful.
3

I can't believe this hasn't been mentioned yet...

Java runs on many different devices (Win, *nix, Mac, cellphones, pas, etc. including x86, arm, and some embedded devices whose opcode is bytecode)

C# runs on 1 (well 4 if you count 2k,xp,win7 beta and win7 as 'different') os on 1 architecture.

Someone will mention mono at this point. Mono is a mistake; a lagging-far-behind implementation of .net that MS hasn't sued anyone over, but claims they can. It is not complete, (will never be) and generally lags real .net by at least a major version.

6 Comments

Whether you regard Mono as a mistake or not, it definitely runs code which was compiled from C# on non-Windows platforms, invalidating your third paragraph.
Mono enables that - that's true, but multiplatform performance was one of the fundamentals of Java design. It's made to run everywhere (and it runs almost EVERYWHERE!). Moreover Java has an open implementation and is released under GPL. C# equals Microsoft and the design of the language is dictated by the MS goals - you like it or not, it's true.
@Jon And NASM runs code compiled from assembly on non-windows platforms. That doesn't make the output portable. .net is portable to mono: Unless you used window.forms, linq-to-sql, wpf, wcf, wf, system.management, or system.enterpriseservices. Or .net 4.0. Or native code. Mono is only "cross-platform" in the same way C++ is.
@Jon NASM, the language is also 'portable'. Given sufficient time, I could write an interpreted language emulator for any ISA and make it 'portable'. C# and .net are, by design, tightly integrated. Unless someone specifically qualifies their statement I, and most people, assume C#/.net.
@kts: NASM isn't a language. It's an assembler. Where is the "NASM language specification"? I don't believe that you really can't see the difference between a language which was designed to be portable and which does have a VM on non-Windows platform and a language which deliberately targets x86 and x64. The simple fact is that I can sit down at my Linux workstation, create a program C#, compile it and run it. That completely flies in the face of your post. Your failure to recognise the difference between .NET and C# doesn't remove that difference. The question talks about languages.
|
2

Java runs on relatively more platforms than C# (or .NET)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.