tags:

views:

970

answers:

20

I want to know why I should learn C#?

What features does C# have that Java does not?

+8  A: 

There's a whole lot of differences: http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java

Whether you should use one over the other depends on your priorities. What do you want to write in them?

Welbog
+3  A: 

There is a nice article on the subject here. And it starts comparing C# and Java.

Gorpik
A: 

More important than the feature of the language are the run-time environment and the libraries.

C# and Java have a different set of libraries, frameworks, operating system interactions, etc.

ChrisW
+9  A: 

C# is an object-oriented high-level language which can be useful to develop applications.

It supports getter/setter constructs, delegates and true generics, which Java does not. C# usually feels more "native" on Windows, since Windows.Forms and WPF are closer to native code than Swing. However, Java is more cross-platform than C#(even though project "Mono" is changing that)

luiscubal
Swing, as what I'd do from a noose if I had to use a Java desktop app.
Will
There are plenty of great java desktop applications, but I agree native code will always be better than JVM. Regardless, its not about what language the app is written in - its what the app allows you to accomplish that counts.
Syntax
@Syntax: I never said Swing was unsuitable for application development. In fact, I'm mostly a Swing programmer and I haven't had many problems so far because Swing provides a laf system.
luiscubal
Just my opinion but shouldn't C#'s Windows.Forms and WPF be compared to Java AWT instead of Swing?
Esko
AWT tries to be platform specific and provide native support to UI widgets while Swing tries to be the cross-platform one. Considering .Forms and WPF both _are_ platform specific it would seem to me at least more natural to compare those to AWT directly instead of Swing. End result is the same tho'.
Esko
Actually, it seems Windows.Forms should be compared to AWT and WPF to Swing. After all, Windows.Forms/AWT are the closest to native and WPF/Swing are written in mostly Managed/Java code...
luiscubal
+2  A: 

You should learn both, and use each of them as appropriate. I don't feel like it's a "which one should I learn?" kind of question. (Or a "I know Java, why should I learn C#?" question.) That comparison that Welbog posted will help you decide when to use one over the other. But, myself, I like having both in my toolkit.

JMD
+4  A: 

C# (and other the CLR languages) have aspects of functional programming (such as delegates and closures) that make some types of development and design patterns easier. See this post by Steve Yegge for more. Delegates can make code much more expressive and concise.

Bob King
+1  A: 

This question here on SO might also help: http://stackoverflow.com/questions/58595/should-i-learn-c-or-java

xan
A: 

The biggest reason, imho, why is because (for windows desktop apps at least) Java UI is godawful ugly. Fugly ugly. Vomitously ugly. Ugly like the kid you'd have if you impregnated your sister.

If you are required to run on any OS, Java is your best option (tho Mono is catching up!). But if you're programming for the Windows environment, C# is a dream to code and looks like any other native application.

Other than that, I'd say Linq. And the ability to fail fast on exceptions rather than having to handle exceptions everywhere (like we actually know how to handle each and every exception). Oh, and Linq again. Linq is so beautiful... to me... Can't you see?

Crap, forgot about lambdas. Damn, I love lambdas and all their closure goodness.

Will
Are you actually using the Windows look and feel?
Neil Coffey
Have you actually looked at Window's market penetration lately? I know its crazy, but apparently lots of people are using and coding for windows boxes.
Will
+1  A: 

the only reason you should is because you want to

C# is a

multi-paradigm programming language that encompasses functional, imperative, generic, object-oriented (class-based), and component-oriented programming disciplines

so you get to learn a lot of tricks from different paradigms, all in a single language

BlackTigerX
+2  A: 

There are lots of questions that people have asked on this topic already. Read up, they've got good infos there. :)

Robert P
A: 

Based on the question seems like you are not interested in learning it for the sake of knowing more about programming and clearly looking for practical reasons.

That is why I don't think you should bother learning it, since it will be just another tool to accomplish same thing in your toolbox.

moose-in-the-jungle
+2  A: 

Syntax: They are both reasonable languages--they support pretty much the same high level structures and designs (OO, encapsulation, ...) and are fairly equal up until you get down to the code level (which overall isn't that big a deal. C# beats java in features, Java beats C# in simplicity I guess).

Portability: My biggest factor has been that lately I've worked on apps for a spectrum analyzer and upcoming cable systems. Neither would have been remotely programmable in C# (you are completely reliant on microsoft to port the runtime to your platform of interest. Java is open source (there may still be one or two little pieces that aren't, but they are sincerely working on that and it's enough that you can port it and use it just about anywhere.

If you are only ever interested in Windows and if you'd like to take advantage of tight, simple integration with windows, then C# is the platform for you.

VM Both languages include a "Runtime" that can support other languages--and those other languages generally have access to the (very rich) libraries provided in each environment.

Microsoft can run a few (a dozen) languages on it's VM, none as impressive as C# (although Ruby and Python could be good--are they fully available yet)?

The JVM has a few hundred including some cutting-edge experimental languages that often run as well as or better than their native counterparts. Some are considered the next generation in programming, as different from Java/C# as they were from C. I looked into Scala, but I must be getting old, it just hurt my head, but I admit there are some very advanced concepts available in there. Groovy rocks.

System integration/tools: C# wins hands down since Java can't commit to any one platform. C# is also very well integrated with databases and other external dependencies, Java is getting better integrated, but the tools are a little more mismatched. C# the entire toolset tends to be very integrated since it all tends to come from a single vendor.

Number of platforms using it (number of potential customers): Last I heard, Java wins hands down. WAY down. Every try to figure out how many phones, microwaves, TVs and toasters might be running Java? The number dwarfs every other language combined as I understand it...

Bill K
You think Java runs on more platforms than C?
Phil Nash
I wouldn't have until I heard it. It was on the news--like more physical running java environments than all others put together. I was as surprised as you. They explained it as all the embedded JVMs.
Bill K
Bill - its very doubtful that the number of java applets on cell phones out number the actual software for computers, plcs, consoles, and just about anything else.Microwaves don't run java. I did find a coffe pot that will run .net though. It costs about $1100.
Syntax
I believe, to be specific, the news story I heard was about number of devices running programs written in a specific language, and I believe the difference was HUGE, like 2:1 java over anything else. Also--you'd be surprised what runs java, it's not always exposed.
Bill K
A: 

I like what Welbog wrote. I would add that it would also depend on where you're at professionally, your interests, and your job prospects /interests.

If you're you've just started to learn Java, then picking up a little C# might help in terms of broadening your programming horizons. The languages are similar (roughly speaking), but of course there are nuances to say the least in programming in one versus another. If you've been programming Java for awhile, then perhaps you'd be better off either expanding your J2EE area of expertise or maybe looking at other supporting areas and/or languages.

In terms of job prospects, you might find companies in your area hire more .NET developers than Java, or vice-versa. You might also want to look at companies you want to work for and make sure your skill set matches. For example, if you've dreamed at working at a particular firm who uses JSP, just as an example, then sticking with Java would be better.

Anjisan
+1  A: 

Simple answer -- C# is the primary language for developing Micorosft applications at this point. Learning it opens up a new world of potential opportunities to work on Microsoft-based applications.

Also, it's not really that hard to learn. Just a little harder than VB was, but with lots of OO power.

Some people would say C# is Microsoft's Java -- actually they look almost identical, just minor differences but different class libraries. If you already know Java, picking up C# shouldn't be too hard.

alchemical
A: 

It is not C# that you should want to learn but .NET Framework and related technologies. Think rather J2EE vs .NET. Why would you want to learn .NET? It's up to you to decide. Like Java it's one of the few major development platforms. It is functional, very actively developed and supported with a huge community knowledge base.

User
A: 

I can't believe nobody has posted this yet..

Because, it is a fun language. Personally I think Java is a rather nasty language (still can be fun), but not as enjoyable as C#.

David Anderson
I'm curious about what you find "nasty" in the java language.
Logicalmind
Conventions mostly. Things like "swing" make absolutely zero sense. Also, the Java UI stuff (not web) is absolutely the ugliest thing I've ever seen.The language is powerful and useful, but I don't think I'd ever buckle down and touch it again with so many better languages out there.
David Anderson
A: 

To me the choice is as simple as I need to use .NET libraries, so I'll use C# or I need to use Java libraries so I'll use Java. If I'm working on something on a Windows client I'll use C#, if I'm working on something that needs to run against the P6 Integration API I'll use Java.

You shouldn't feel like you you are missing something or should use one or the other. Look at what you have to do and pick the best tool for doing that.

It's tough to list on a post here all the features of the .NET Framework, just like it would be tough to list all the features contained in the Java SDK Libraries.

bruceatk
A: 

Learning C# because it may or may not have features that Java doesn't have seems like a very odd reason in opinion (it does have a number of features, that Java doesn't but so does F#, LISP, Haskel, Ruby, Lua and even COBOL).

You should learn C# because

  • You need to (to keep or get a job, stay in school, whatever)
  • You want to
  • It is fun to expand your horizon
  • Any or all of the above
Brian Rasmussen
A: 

There are some syntactic sugar advantages in .NET such as LINQ or Properties. (Yes, you don't have properties - not to mention auto-properties - in Java).

Andrei Rinea
A: 

Do you need to learn C#?

Is your job situation going to improve?
Do you want to learn something new?

Is the development environment better in C#, is the tooling better?
Do you think you can do something in C#, that you can't do in Java?

Maybe a generic language for desktop, web and mobile - but Java has this as well.

Just a few questions you could use to decide.

I'm C# myself, started out in Java when I was introduced to programming. I think Java did a fantastic job for me in understanding programming, mostly because there were no magic IntelliSense, or form designer for Windows apps - we had to write the whole damn thing our selves. Which was good, when you're learning. But I think C# and the whole .NET/Visual Studio eco-system enables you to be more productive.

MartinHN