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

Community
  • 1
  • 1
Lars Andren
  • 8,601
  • 7
  • 41
  • 56

4 Answers4

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.

Community
  • 1
  • 1
sblom
  • 26,911
  • 4
  • 71
  • 95
3

Have a look at

Comparison of Java and C Sharp

Java vs C#/.NET

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284
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.

KitsuneYMG
  • 12,753
  • 4
  • 37
  • 58
  • 2
    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. – Jon Skeet Apr 13 '10 at 05:28
  • 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. – trzewiczek Apr 13 '10 at 10:32
  • @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. – KitsuneYMG Apr 13 '10 at 13:18
  • @kts: The *language* is portable, even if not all the libraries are. You should distinguish between those things. For example, someone could perfectly easily write a Mono application using standard C# and my Protocol Buffers port. They may want to target GTK# instead of WinForms - who knows? The point is that it's C# running on non-Windows. If you want to claim that .NET itself only runs on Windows, that's an entirely different matter. – Jon Skeet Apr 13 '10 at 13:43
  • 1
    @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. – KitsuneYMG Apr 14 '10 at 04:12
  • 2
    @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*. – Jon Skeet Apr 14 '10 at 05:18
2

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

anonymous
  • 3,474
  • 25
  • 29