Jump to content

  • Log In with Google      Sign In   
  • Create Account


Differences between C# and Java


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
18 replies to this topic

#1 stein102   Members   -  Reputation: 475

Like
0Likes
Like

Posted 04 February 2012 - 02:20 AM

Right now I am programming in Java and enjoy it, I've made some decent progress, but in no manner would I refer to myself as a master. I would like to transition over to C# sometime, and would like to know some of the similarities and differences between the languages. I am mainly switching so I can use XNA. I'm not sure if now is a good time to switch or if I should stick with Java for a bit longer.

opinions?
Thanks.

Sponsor:

#2 stein102   Members   -  Reputation: 475

Like
0Likes
Like

Posted 04 February 2012 - 02:37 AM

Or would you suggest to just move onto C++, which is my final goal?

#3 fla   Members   -  Reputation: 442

Like
0Likes
Like

Posted 04 February 2012 - 03:18 AM

Right now I am programming in Java and enjoy it, I've made some decent progress, but in no manner would I refer to myself as a master. I would like to transition over to C# sometime, and would like to know some of the similarities and differences between the languages.


You could look at here.

I am mainly switching so I can use XNA. I'm not sure if now is a good time to switch or if I should stick with Java for a bit longer.

opinions?


Imho they are two languages which are close from a programmer's point of view. There are differences, but the main concepts are the same, so the transition shouldn't be hard.

Or would you suggest to just move onto C++, which is my final goal?


Obviously it depends on many factors, the transition to C# should be easier than the C++ one, and you're also considering XNA, which is another element that might help you. So, it depends on your will and your constraints (time, for example): you can do an intermediate step (with some result) or an harder one. Imho, if your final goal is C++ and you've no time constraints and no need to produce results to keep up your motivation, you can avoid learning C# and XNA and jump to C++, imho.
[ Plith ]

#4 Memories are Better   Prime Members   -  Reputation: 769

Like
0Likes
Like

Posted 04 February 2012 - 03:27 AM

I have only used Java briefly so I cant really comment for the whole language but from what I saw it was a lot like C#.

As for C#, it is a great language and the .net framework is amazing but then I havent really tried out other languages outside .net (minus PHP). Sadly if you did a google search you will likely come across hundreds of outdated threads where the languages are compared and degraded, I would avoid reading them simply because the internet in flooded with comparison wars (not just C# / Java) making it really frustrating finding 'real' comparisons and all you really find are "join my club, its better!" threads / articles.

Same applies to C++ vs ??? and well MS vs Apple and whatever else, I would stay clear away from those threads, because if anything they will be outdated and put you off, if you like Java, stick with it, if you want to try C#, go for it and if you want to play around with C++ then by all means do. Be weary of the "unmanaged languages are bad" that follows literally every C++ vs ??? thread / article, if the language was so bad millions of people wouldnt put their blood and sweat advancing in it.

Sorry if that sounds like a rant but I felt it was necessary to say with the amount of comparison articles / threads around :D

As for C# (.net) itself, theres many many features, Linq, EF, XNA, WCF, WPF, SL5 (which now has many features of XNA), ASP.NET MVC (which made all my web related work simple and easy in ways I couldnt imagine) and in the next few months massive improvements to Async programming. Theres many features about .net that havent been mentioned here and really I could go on and on, but tbh if you want to try then try it, theres no reason why a person couldnt advance in every language, learning something in one language will likely benefit you in the other.

In regards to limitations, the main one really is .net is for MS machines only, there mono which helps overcome this limitation, to me this is hardly a limitation, I have never used an apple product, no criticism to apple but I have never had any desire or need to use or buy an apple product.

One thing I will say about C++ though, you may want to check out native C before doing any C++, the learning will be relatively quick and straight forward since most of the language could be easily compared to Java and definitely C#, I did a little bit of reading back in the day with pointers on C++ and oddly enough it was only when I started learning about native C that I actually understood pointers and memory management in general

#5 SimonForsman   Crossbones+   -  Reputation: 5803

Like
0Likes
Like

Posted 04 February 2012 - 04:43 AM

Or would you suggest to just move onto C++, which is my final goal?


If C++ is your final goal then need to reconsider what your final goal should be. (C++ is a good language to know but you're fooling yourself if you think its the only language you need as a programmer), I did consider C++ to be my final goal when i started out and as such it was the fourth (i covered BASIC, Pascal and x86 asm before that) language i learned, now i know over 15 languages and got 2 languages on my "to learn" list, (C# and Python and i'm working on C# atm).

When it comes to learning C++ i strongly advice against learning C first as you risk picking up some very nasty habits that way.

As for C# vs Java, the main differences i can think of is LINQ which is just pure awesome and the platform support, (Java is required for Android development while C# is required for WP7), on the desktop it really doesn't matter which one you go with allthough running .jars on Windows can be a bit of a pain since some stupid applications (WinRAR) insist on stealing the extensions by default. (Packaging them in an .exe or using a launcher solves that problem though)
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!

#6 Marvel Magnum   Members   -  Reputation: 324

Like
0Likes
Like

Posted 04 February 2012 - 12:31 PM

When it comes to learning C++ i strongly advice against learning C first as you risk picking up some very nasty habits that way.


Cannot have agreed more. I had C background and I never thought I would lug around so much excess baggage when I started C++. Even the programming paradigm is different. I took my much effort to get rid of all that baggage and really start to think in C++ rather than think in C and code in C++.

Even the great man himself says --

In the continuing debate on whether one needs to learn C before C++, I am firmly convinced that it is best to go directly to C++. C++ is safer, more expressive, and reduces the need to focus on lowlevel techniques. It is easier for you to learn the trickier parts of C that are needed to compensate for its lack of higherlevel facilities after you have been exposed to the common subset of C and C++ and to some of the higherlevel techniques supported directly in C++.
- Dr. Bjarne Stroustrup


Someone else had rightfully said, "The more experienced C programmer you are, the more time you will take to become a C++ programmer."

#7 Memories are Better   Prime Members   -  Reputation: 769

Like
0Likes
Like

Posted 04 February 2012 - 01:44 PM

Ah, I guess I should have left that C first comment out, truth be told when I checked out C it was really only to get my head around pointers, its hard to explain but I couldnt seem to make much sense of pointers in C++ and when I thought I did references popped up, pointers oddly enough then made sense from a C text.

Oh also I should mention my comment was purely todo with pointers only, I have like a max of 1 week experience from 2010 on both C / C++ and that really was to find out the usefulness of pointers :D, well 1 week and 1 day (decided to check out C++ for the sake of DX)

#8 Telastyn   Crossbones+   -  Reputation: 3722

Like
0Likes
Like

Posted 04 February 2012 - 01:44 PM

and would like to know some of the similarities and differences between the languages.


C# up to 2.0 was essentially 'Java with lessons learned'. It does away with checked exceptions, has a concept for interfaces, a sane DateTime instance, and good generic support. It shared the same sort of OO approach, garbage collection and bytecode ideas.

Since 2.0 (around the same time Java stagnated) C# has added support for dynamic variables/execution, extension methods, generators, expression trees, concurrent data structures in the standard library, and better use of methods as data (including better anonymous method syntax),

This last one is the big day to day difference you'll see between modern C# and Java. Modern C# tends to make fairly heavy use of in-line anonymous methods which are antithetical to the Java way of doing things.

#9 jonbonazza   Members   -  Reputation: 121

Like
0Likes
Like

Posted 04 February 2012 - 10:43 PM

Not to mention the obvious fact that Java is entirely cross-platform (And by the way, converting java code to an exe file seemse counter productive to me, as perhaps the biggest advantage to using java IS its cross-platform nature), where-as C# is Microsoft only (unless you take into account Mono, which is another argument all together).
Co-founder/Lead Programmer
Bonafide Software, L.L.C.
Fairmont, WV 26554 US

#10 daviangel   Members   -  Reputation: 600

Like
0Likes
Like

Posted 04 February 2012 - 11:11 PM


and would like to know some of the similarities and differences between the languages.


C# up to 2.0 was essentially 'Java with lessons learned'. It does away with checked exceptions, has a concept for interfaces, a sane DateTime instance, and good generic support. It shared the same sort of OO approach, garbage collection and bytecode ideas.

Since 2.0 (around the same time Java stagnated) C# has added support for dynamic variables/execution, extension methods, generators, expression trees, concurrent data structures in the standard library, and better use of methods as data (including better anonymous method syntax),

This last one is the big day to day difference you'll see between modern C# and Java. Modern C# tends to make fairly heavy use of in-line anonymous methods which are antithetical to the Java way of doing things.

Ditto.
As a beginner writing trivial small programs you may be forgiven for thinking C# is just Microsoft's version of Java since they are so similar Posted Image
After you learn more and use them for a while you'll start to see they really are different though.
For example, C# has the keyword unsafe which allows you to use pointers which is the a big difference between the languages.
C# being able to use the .Net framework classes allows a lot easier integration with other languages and is tied a lot more with Windows via Winforms, WPF, etc...
On a practical level as a beginner I found C# easier to learn just because Visual Studio helps so much when writing C# code.
Java is just as easy to write from command line but I never found Eclipse to be as easy, enjoyable to use myself.
Also C# seems to be evolving way faster than Java that some of the new stuff like LINQ wasn't even around when I started learning C# that there might be quite different ways to do stuff now.
Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

#11 stein102   Members   -  Reputation: 475

Like
0Likes
Like

Posted 05 February 2012 - 02:03 AM

Thanks for all the great advice and suggestions. I think I will jump into C# as soon as possible. Does anyone know of any good resources for learning C#? Such as books/online tutorials?

Thanks

#12 Marvel Magnum   Members   -  Reputation: 324

Like
0Likes
Like

Posted 05 February 2012 - 04:28 AM

This is a nice tutorial cum presentation on the C# language. Check it out: http://www.jaggersoft.com/csharp_course/index.html

#13 ranakor   Members   -  Reputation: 439

Like
0Likes
Like

Posted 05 February 2012 - 08:30 AM

Not to mention the obvious fact that Java is entirely cross-platform (And by the way, converting java code to an exe file seemse counter productive to me, as perhaps the biggest advantage to using java IS its cross-platform nature), where-as C# is Microsoft only (unless you take into account Mono, which is another argument all together).


I don't know, i wouldn't consider mono being another argument. While it makes sense not to equal mono's other platforms with java platform everywhere, it also has the upside of providing cross platform "without" the cost of "no base platform", because while java may run pretty much anywhere, it doesn't run anywhere by default, most windows computers i know off don't have java installed, but have .net installed.

#14 deebee396   Members   -  Reputation: 100

Like
0Likes
Like

Posted 05 February 2012 - 01:13 PM

The C# from Java Orange Book, here is essentialy a list of the main differances between the language. Might be useful.

#15 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 05 February 2012 - 02:58 PM

You could also just jump into Visual Studio and try to recreate a small program you did in Java. You would be surprised to see how easy you will get around. However after a while, as someone said above, you will notice things start to get a bit different, but in a good way (they get easier IMO :) ).

#16 jonbonazza   Members   -  Reputation: 121

Like
0Likes
Like

Posted 06 February 2012 - 10:40 PM


Not to mention the obvious fact that Java is entirely cross-platform (And by the way, converting java code to an exe file seemse counter productive to me, as perhaps the biggest advantage to using java IS its cross-platform nature), where-as C# is Microsoft only (unless you take into account Mono, which is another argument all together).


I don't know, i wouldn't consider mono being another argument. While it makes sense not to equal mono's other platforms with java platform everywhere, it also has the upside of providing cross platform "without" the cost of "no base platform", because while java may run pretty much anywhere, it doesn't run anywhere by default, most windows computers i know off don't have java installed, but have .net installed.


Most populate linux distros come with java pre-installed. No OSs come with Mono pre-installed.
Co-founder/Lead Programmer
Bonafide Software, L.L.C.
Fairmont, WV 26554 US

#17 arbitus   Members   -  Reputation: 436

Like
0Likes
Like

Posted 07 February 2012 - 09:53 AM

Most populate linux distros come with java pre-installed. No OSs come with Mono pre-installed.

I don't believe that is true, as I believe both Ubuntu and Fedora are distributed with Mono. I really have not bothered checking other distros for this though.

Edit: It looks like GNOME requires Mono, as some of its components use it, especially Tomboy. So any distro that uses GNOME is going to require Mono by default.

#18 Serapth   Crossbones+   -  Reputation: 5181

Like
0Likes
Like

Posted 07 February 2012 - 01:32 PM


and would like to know some of the similarities and differences between the languages.


C# up to 2.0 was essentially 'Java with lessons learned'. It does away with checked exceptions, has a concept for interfaces, a sane DateTime instance, and good generic support. It shared the same sort of OO approach, garbage collection and bytecode ideas.

Since 2.0 (around the same time Java stagnated) C# has added support for dynamic variables/execution, extension methods, generators, expression trees, concurrent data structures in the standard library, and better use of methods as data (including better anonymous method syntax),

This last one is the big day to day difference you'll see between modern C# and Java. Modern C# tends to make fairly heavy use of in-line anonymous methods which are antithetical to the Java way of doing things.


C# has aged much better than Java, I think there are few that would argue that. With very few exceptions ( non-generic datatypes like ArrayList ), their are very few legacy warts in C#, unlike Java, while it has implemented new language features, like generics, much cleaner than Java.


That said, I don't know if C# just commited a cardinal sin implementing dynamic. For such a safe language, it seems like such a glaring and horrible hole smashed into the design. I can't help but wonder if Anders suffered a bit of language envy of Ruby or Javascript at the time and tried to make C# a be-all language. I guess only time will tell.

#19 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 07 February 2012 - 02:34 PM

That said, I don't know if C# just commited a cardinal sin implementing dynamic. For such a safe language, it seems like such a glaring and horrible hole smashed into the design. I can't help but wonder if Anders suffered a bit of language envy of Ruby or Javascript at the time and tried to make C# a be-all language. I guess only time will tell.


Well, the tools are there, you can use them or you can pass. I currently work at my job with WPF, WCF, Entity Framework and some other "modern" .net stuff, however using them has a lot of drawbacks, especially performance wise. So I'm glad they keep adding new stuff, but then none is force to use it.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS