What language is better to learn - C# vs. Java

Started by
17 comments, last by ATC 11 years, 6 months ago
Hi all!

I'm a rather experienced DarkBASIC user who is currently trying to learn new, more versatile languages. I've dabbled in everything from Python to C++ and everything in-between but haven't officially started learning much of anything from them yet. I can't decide which is better to learn.

I'm quite interested in multi-platform development, so naturally Java seems to be the better route to go, but I'm also aware that the MonoDevelop project allows .Net code to run across all platforms these days, so C# sees a safe bet as well. What's your personal opinion?

Personally, I think C# looks a little friendlier, and in Unity it makes a lot more sense for scripting, but I'm also interested in general applications as well. Should I just learn both?

Thanks for any insight!

My website! yodamanjer.com
My development blog!

Follow me on Twitter! [twitter]jwg1991[/twitter]

Advertisement
C# and Java are reasonably similar and are both popular, so either would make a viable choice. If your instinct says C# looks "friendlier" you should probably just go with that, as a large part of the choice is simply personal preference. If you're interested in Unity that's obviously also a point in favour of C#.

If you're already reasonably experienced and want to make a more informed choice you could consider trying both languages to make your own comparison. Pick a few relatively simple tasks (create a window, draw a sprite on screen, read input from a file, etc.) and try to do them with both languages. You'll then have a better idea of your own personal experience and opinion with each.


Personally given the choice of those two languages I would choose C# -- a few design decisions in Java and it's accompanying libraries put me off of it a bit.


I'd say your best bet is to try both!
Hope that helps! smile.png

- Jason Astle-Adams

My personal choice would be C# too, but language-wise they are similar enough that learning one and you will cover 90-95% of the other. I think that the frameworks and IDEs are more important factors than language syntax in this case.

openwar - the real-time tactical war-game platform

Not much point "learning" both at this point since they're so similar, i use both and like both for various tasks. The main advantage C# has for games is XNA and Unity, there just isn't any real competitors to those frameworks/engines in Java. (There are great libraries for Java aswell but they're not as easy to use imo)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
I used to program in Java in school, but professionally I turned out to be a C# developer.

Personally, I'd go with C# just for the fact it's a heck a lot easier to interop with native code. And you have a finer control over memory, e.g. structs, unsafe code, etc.

FYI, whatever you choose...for Java - jMonkeyEngine, Ardor3D are two of the more well known graphics engines out there, and LWJGL for a good OpenGL binding.
Java is more cross-platform than C#.
However you can use C# with Unity and XNA, they both increase portability, which probably is not possible through language itself.

It depends what kind of portability you're looking for. If you wish to create apps for phones you can use C++ with some library (or w/e it's called), for example Marmalade, or create own one: create small Java (Android) or Objectivec (iOS) program that would run your C++ program and there you go, it's portable (my friend does this at his work).
It depends what kind of portability you're looking for.[/quote]

Well, I'm not really looking into mobile options yet (though I do plan to develop for WP8+ and Android, eventually), I was just talking about desktop platforms.

...language-wise they are similar enough that learning one and you will cover 90-95% of the other.[/quote]

Yeah, I had heard this previously from other places, and sort of experienced it when I tried out coding in Java after studying C# for a day sometime ago. There were still quite a few differences, but it was just syntax - the basic structure seemed to be completely the same.

Thanks for your input, everyone! Sounds like C# is the way to go for now. :)

My website! yodamanjer.com
My development blog!

Follow me on Twitter! [twitter]jwg1991[/twitter]

My first real language that I taught myself (other than web script languages) was C#. It's still my favorite for general purpose applications. C# isn't the best for cross-platform, but if you are mostly going to write Windows applications, C# and the .NET Framework offer you more. Finally, once you know C#, Java comes secondhand, they are *very* similar.
Here's a short list of features that C# has that java doesn't. To be quite frank, C# was really designed to be a 'better' Java, and has succeded in many aspects.

http://msdn.microsoft.com/en-us/library/s1ax56ch.aspx - Value types vs. reference types
http://msdn.microsoft.com/en-us/library/dd264739.aspx - Named and optional arguments
http://msdn.microsoft.com/en-us/library/8627sbea.aspx - Built-in events
http://msdn.microsoft.com/en-us/library/bb397687.aspx - Lambda expressions
http://msdn.microsoft.com/en-us/library/d5x73970.aspx - Value types allowed as generic parameters; generic constraints
http://msdn.microsoft.com/en-us/library/ee207183.aspx - Co/contravariance
http://msdn.microsoft.com/en-us/library/ms173171.aspx - Delegates
http://msdn.microsoft.com/en-us/library/9fkccyh4.aspx - Methods are not overridable by default
http://msdn.microsoft.com/en-us/library/e59b22c5.aspx - Better interop support with unmanaged code
http://msdn.microsoft.com/en-us/library/y31yhkeb.aspx - Pointers
http://msdn.microsoft.com/en-us/library/x9fsa0sw.aspx - Properties (getters/setters)
http://msdn.microsoft.com/en-us/library/8edha89s.aspx - Operator overloading
http://msdn.microsoft.com/en-us/library/hh156513.aspx - 'async' methods
http://msdn.microsoft.com/en-us/library/ms229005.aspx - More flexible exception throwing*
http://msdn.microsoft.com/en-us/library/5cyb68cy.aspx - Ability to allocate memory not managed by the GC
http://msdn.microsoft.com/en-us/library/system.io.aspx - Standard IO library that is not complicated and overly verbose
================================================================================
* adding 'throws' to a method in Java requires snowballing changes to all methods that make use of that method, which requires changes to those methods, etc...
http://hexus.net/mobile/news/android/38789-google-android-ported-java-c-blazing/


Also, Java being more portable than C# is partially incorrect. Through Mono, you can compile C# code for a huge variety of platforms including Linux, Mac, PS3, and loads more I can't remember.

The only problem with C# is that we'll never know if it ends up being a microsoft patent trap.

http://msdn.microsof...y/ms229005.aspx - More flexible exception throwing

That's wrong cos Java offers checked and unchecked exceptions.


http://msdn.microsof...y/ee207183.aspx - Co/contravariance

What feature doesn't Java possess??

This topic is closed to new replies.

Advertisement