*
The moose likes Beginning Java and the fly likes Why and How Java is better than C#? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why and How Java is better than C#?" Watch "Why and How Java is better than C#?" New topic
Author

Why and How Java is better than C#?

Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

Hi To All Java Wizards,
A very tiny question comes in mind at first foot step on career development path is that which language is better and gives me growth in IT industries? i.e. Java or C#. Both are Object Oriented and mostly C# has more features than Java by this link

http://en.wikipedia.org/wiki/Comparison_of_Java_and_C_Sharp

on Wikipedia.
Just a confusing answer and diverting also, for many Java newcomers. In my opinion, One of the main reason for studying language on professional basis is for earning more and more, Interest for language comes at next place; here. So, selection of proper language always matters. How could anyone select from above these? Means, which is better?


MCSA 2003 | Preparing For OCPJP/SCJP6
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1817
    
    7

Why limit yourself to a single (scripting) language or platform? Multidisciplinarity is key.
Java is not 'better' than .NET/C#, nor is .NET/C# 'better' than Java. They're different.
Depending on the problem you're trying to solve and the context in which you are trying to solve it, one might be better suited than the other.
The right tool for the right job, so to speak. So compare features, benefits and drawbacks, and pick the one that suits your needs/expectations best.
But which ever one you pick, don't make the mistake of ignoring the other.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14337
    
  22

Why and How Java is better than C#?

This is a subjective question. There is no absolute answer based purely on neutral facts. And which of these two languages will give you the best career opportunities is also not an easy to answer question; if you're a good programmer in either of these languages, you'll be able to find work.

I agreee with what Jelle said; don't limit yourself to strictly one language.

Did you expect Wikipedia to have a clear answer saying that Java is better? Keep in mind that Wikipedia is an encyclopedia, which tries to be as neutral as possible, it will not give you any opinions to believe in.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

On the "personal opinion" side, C#-the-language has continued to evolve, where Java-the-language has largely stagnated (some of the reasons for the stagnation are technical and arguable, some are more political). I believe C# to be incrementally better than Java, with a few caveats... but there are *substantially* better languages than both, so it's not something I think about very often. C#-the-platform isn't a reasonable choice for me, though, for non-technical reasons.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18962
    
  40

David Newton wrote:On the "personal opinion" side, C#-the-language has continued to evolve, where Java-the-language has largely stagnated (some of the reasons for the stagnation are technical and arguable, some are more political). I believe C# to be incrementally better than Java, with a few caveats... but there are *substantially* better languages than both, so it's not something I think about very often. C#-the-platform isn't a reasonable choice for me, though, for non-technical reasons.


I too, like C# a little bit more than Java, but that is probably more caused by my liking of Visual Studio... ... and the fact that I don't get to use it much (in some years, not at all), so its kinda like a treat when I do.

There are also *substantially* worse languages than both, so it's not something I think about often either.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4457
    
    8

Henry Wong wrote:
There are also *substantially* worse languages than both, so it's not something I think about often either.

And plenty that are substantially worse and better than both, depending on who you speak to .
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19755
    
  20

Of course no language can ever beat LOLCODE.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Like, barf, man, Valgol totally kicks LOLCODE's ass.
mike ryan
Ranch Hand

Joined: Aug 08, 2010
Posts: 210

HI,

I would like to ask a question within this question, which would be the better language to learn first? I am learning JAVA now,is it easier to go JAVA->C# or C# -> JAVA or does it matter at all?


Thanks
Mike
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Doesn't matter in any practical way.
Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

Dear Mike,

In my opinion Java is better for learning first, because C# is a hybrid language ; Microsoft always tries to pick all important features of many Object Oriented languages and put it in a single language known as C#. Version per version, Microsoft do implement new features to make it(C#) stronger and complex in respect to Java.

So, in my opinion your learning ladder should be Java --> C#.
Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

Dear Jelle,

I am partially satisfied with your answer regarding this question. But not completely, I thought learning both is better but proficiency and for profession only one language is more suitable than to be both. Being knowledgeable and being professional are two different things.
Jagadeeswara Yaramala
Ranch Hand

Joined: Jul 28, 2010
Posts: 46
One of the main reason for studying language on professional basis is for earning more and more, Interest for language comes at next place;........


From the (money) earning point of view, Languages (C# or Java or PHP) do not matter !! If you can sell your expert PHP skills....probably one may be earning more than the 'basic' skills in Java or C#. The point is your expert level in a given language and how better you can sell that.

If you go to some of the job sites (In India, naukri.com etc), you can compare the salaries for C# and Java job postings.(In my opinion, as of now, Java jobs get well paid than C#). These things may change based on what oracle will do for Java. On the other side, C# is getting newer versions and added features.

One more thing, enterprises (the companies which will get us the jobs) think on total cost of software application. In this respect, Java is better (Open source)
With C# applications, the enterprises need to buy lot of software licences and hence the cost goes up for them.
If one sees, how many projects(and hence number of jobs and demand for professionals) were deployed in Java and C# for the big companies (Fortune 1000), Java scores higher and higher.

[P.S: All these are my opinions]
Elchin Asgarli
Ranch Hand

Joined: Mar 08, 2010
Posts: 222

If one of them would be better in everything, the other one would simply not exist ;) Thus you can not objectively say Java/C# is better.


Personal page, SCJP 6 with 91%, SCWCD 5 with 84%, OCMJD
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


In my opinion Java is better for learning first, because C# is a hybrid language ; Microsoft always tries to pick all important features of many Object Oriented languages and put it in a single language known as C#.

Not sure why this matters. All languages have picked good (and sometimes bad) ideas from languages that preceded them.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

Jagadeeswara Yaramala wrote :
If you can sell your expert PHP skills....probably one may be earning more than the 'basic' skills in Java or C#. The point is your expert level in a given language and how better you can sell that.

If you go to some of the job sites (In India, naukri.com etc), you can compare the salaries for C# and Java job postings.(In my opinion, as of now, Java jobs get well paid than C#). These things may change based on what oracle will do for Java.

One more thing, enterprises (the companies which will get us the jobs) think on total cost of software application. In this respect, Java is better (Open source)
With C# applications, the enterprises need to buy lot of software licences and hence the cost goes up for them.



Elchin Asgarli wrote :
If one of them would be better in everything, the other one would simply not exist


100% Correct In my opinion. But, this confusing question makes a misery for programmers. More Votes come to Java because Java is an Open Source Language. But, in complexity and strength, C# comes first. And C# is not easy to learn as Java; by the increment in its version per year.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Elchin Asgarli wrote:If one of them would be better in everything, the other one would simply not exist ;) Thus you can not objectively say Java/C# is better.

I disagree completely; that's not how businesses operate. There are lots of things that exist for which completely better alternatives are available, yet they exist, for a variety of reasons.
Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

Dear David,
ya it is right that always alternative exists for all. But alternative may or may not be your right choice in programming field for choosing proper language for learning and earning both. As I have told earlier, study is mainly exists for more and more earning and success not only for knowledge. And, always human being tries for shortcut to success which is not always being available.

So, alternative doesn't mean to us as a programmer. and no one is perfect in each and every ways.
Elchin Asgarli
Ranch Hand

Joined: Mar 08, 2010
Posts: 222

David Newton wrote:
Elchin Asgarli wrote:If one of them would be better in everything, the other one would simply not exist ;) Thus you can not objectively say Java/C# is better.

I disagree completely; that's not how businesses operate. There are lots of things that exist for which completely better alternatives are available, yet they exist, for a variety of reasons.


Can you name any? Something that would be better than the other thing in ALL(!!!) aspects.

Plus this is definitely not the case for Java and C#.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Elchin:

COBOL, for one. Of course, the cost of change has not been accounted for, which will be a large factor for the business-types when they're making the decision to change.

John.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
COBOL applications executing on a mainframe are still much faster than anything written in Java or C++.

The point is that in some situations for some requirements, COBOL is the BEST option.

That is why at least 80% of the world's financial systems are using COBOL and they will continue to use COBOL for the next 20 years.

However, for fancy web pages and such Java is the BEST option.

Mainframe COBOL executes MILLIONS OF INSTRUCTIONS PER SECOND...that is MILLIONS in a single second. A JRE will never be able to compete with this
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Frank Bennett wrote:COBOL applications executing on a mainframe are still much faster than anything written in Java or C++.

I really haven't found that to be the case.
However, for fancy web pages and such Java is the BEST option.

Best in what way?!
Mainframe COBOL executes MILLIONS OF INSTRUCTIONS PER SECOND...that is MILLIONS in a single second. A JRE will never be able to compete with this

That's a bizarre claim.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
I really haven't found that to be the case


The really depends upon your particular experiences doesn't it. How much COBOL programming have you done and what are the data file sizes that you have worked with?

The other aspect to consisder is the data storage mechanisms and the relationship between the database and the applications. Oracle has very powerful Pro*COBOL components that enable extreme data processing speeds.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Frank Bennett wrote:
The really depends upon "your" particular experiences doesn't it. How much COBOL programming have you done and what are the data file sizes that you have worked with?

Of course, and the reverse is also true--it depends on "your" particular experiences as well. I've done as little [COBOL programming] as humanly possible. Tens to hundreds of millions of records, depending.

Tell me again how the JRE doesn't execute millions of instructions per second, particularly one with a good JIT, and why Java is the "best" option for creating fancy web pages. Extraordinary claims demand extraordinary proof.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Forum responses are not "proof" of anything. Just as "claims" of experience and all the other text-based nonsense that we find on Internet web pages is not "proof."

Hopefully this is simply a healthy exchange of "ideas" and "opinions." Java is the best because I feel it is the best for creating fancy web pages. And my feelings are really the other things that matter
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11471
    
  16

In my mind, these are all meaningless questions. Would you ask "which is a better tool - a hammer or a wrench?" if someone did, the first response would be "do you want to drive a nail, turn a nut, or saw a board in half?" since depending on the answer to that, the answer to the original question will change.

Simply asking "why is technology 'a' better than 'b'" is equally meaningless unless you know what you want to use the technology for.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14337
    
  22

Frank Bennett wrote:Mainframe COBOL executes MILLIONS OF INSTRUCTIONS PER SECOND...that is MILLIONS in a single second. A JRE will never be able to compete with this

Really? Let's try a simple, small Java program:

This adds up ten million numbers and prints the result.

How long so you think this Java program takes to run? On my laptop (a standard MacBook Pro) it takes about a quarter of a second. Wow! That means it executes TENS OF MILLIONS OF INSTRUCTIONS PER SECOND. Do you still want to claim that the JVM cannot compete with MILLIONS OF INSTRUCTIONS PER SECOND of COBOL running on a mainframe?

People do not use COBOL and mainframes because they are so fantastically fast. If you think they are, please provide some real proof.
Elchin Asgarli
Ranch Hand

Joined: Mar 08, 2010
Posts: 222

Jesper Young wrote:
Frank Bennett wrote:Mainframe COBOL executes MILLIONS OF INSTRUCTIONS PER SECOND...that is MILLIONS in a single second. A JRE will never be able to compete with this

Really? Let's try a simple, small Java program:

This adds up ten million numbers and prints the result.

How long so you think this Java program takes to run? On my laptop (a standard MacBook Pro) it takes about a quarter of a second. Wow! That means it executes TENS OF MILLIONS OF INSTRUCTIONS PER SECOND. Do you still want to claim that the JVM cannot compete with MILLIONS OF INSTRUCTIONS PER SECOND of COBOL running on a mainframe?

People do not use COBOL and mainframes because they are so fantastically fast. If you think they are, please provide some real proof.


Are you sure that compiler does not perform any optimization thus does not decrease the number of actual instructions? I think more accurate measure would be to print the result of every addition, and then calculate separately how much does it take for the print operation itself by printing the same thing 10000000 amount of times, and then subtract numbers. Stub would be as follows:



I dont have a compiler in my current PC, so can't test it myself
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
LOL, does the example above accuratley represent complex, "number-crunching" algorithms used to efficiently process multi-terra bytes of data?

What about related I/O operations for mulltiple files? What about database operations for each pass? To mention a few common aspects of "real" data processing... nice try though!
Gaurav Raje
Ranch Hand

Joined: Jul 23, 2010
Posts: 136
Thought of getting back to the topic

Arguments in fsavor of Java
1) Platform Independance... how muchever microsoft boasts of platform independance, it has never achieved it.
2) Checked Exceptions - even though heljsberg denies this, checked exceptions are definitely a boon to java
3) Memory management and garbage collection - Studies have shown a statistically better memory management at the end of program
4) Good support in the open source world - Java being free, many open source libraries are based on it. Linux junkies prefer java over srewy C# codes
5) Simpler to write without a GUI IDE..... So in short a simpler language. Come on guys how many of you have ever written a meaningful program in notepad in c#....
6) It came earlier... many companies adopted it.

Arguments in favor of .NET(It pains to write this part)
1) Syntactic sugar. Everything has a better way of writing. Properties replaced bean conventions. Indexers replaced get methods. and many things happened making life easier for programmers.
2) Delegates added more robustness to desiging.
3) Support for functional programming (lambda)
4) LINQ - this topic might take up another thread
5) Entity Framework - competing with hibernate but i really like it
6)Better thread support. They have thread models for more security. They have a good way of invoking threads and other support.Delegates make thread code more readable and better
7) Robust IDE... no need for hunting for 5 different tools. Everything is packed in one.

I could go on.
I love java as a language. But the support provided by microsoft is quite tempting for many companies to switch over. Morever, microsoft has combined licensing. So if you go for one product, they may tempt you with combined offers. I remember our company made a switch from CVS to TFS just because they were switching from MY SQL to SQL SERVER . .... Very much in a similar fashion, microsoft was trying to sell off licenses to our company. They cost differecne between a single team license and the whole organization license was very less as a result of the package.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

I've been a Java developer for about 13 years now, but I do know a small amount about C sharp. C sharp is essentially a copy of Java, which Microsoft created when legal challenges stopped them from innovating/polluting their version of Java licensed from Sun. That means C# looks a lot like Java, in the syntax, libraries, and platform. It includes some innovations which Java has been slow to implement like closures, better generics, and an easier packaging format, and probably others I don't know about. Whether these are improvements or unnecessary complications is a matter of opinion and the subject of much debate.

My big problem with C sharp is (discounting Mono for the moment) it locks you into an inferior OS (Windows) and a terrible app server (IIS). That lock-in is a detriment that's unlikely to go away in future releases.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Frank Bennett wrote:LOL, does the example above accuratley represent complex, "number-crunching" algorithms used to efficiently process multi-terra bytes of data?

What about related I/O operations for mulltiple files? What about database operations for each pass? To mention a few common aspects of "real" data processing... nice try though!

Again: show us the benchmarks--that's all we're asking (along with versions and code). COBOL on mainframes *does* do some things quite well, but I'd still stack up a wad of commodity hardware and Java-based map/reduce against a mainframe and COBOL for lower TCO with same-order-of-magnitude performance.
Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

I think,

This question has NO ANSWER in ACCURATE. Because, wizards are diverting from the main language stream provided i.e. Java Vs C# . And all of them have their own opinion which contradict each other in many respects . One who loves Java would not like to see any thing in favor of C#, Other Loves C# would not like to see any thing in favor of Java; and few strange behavior of them likes both.


So, not getting the correct and accurate answer which will satisfy any programmer in favor of Java or in favor of C#. Means, still standing on this confusing road; and waiting for a proper guide.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Vishal Kashyap wrote:I think,

This question has NO ANSWER in ACCURATE. ....

So, not getting the correct and accurate answer which will satisfy any programmer in favor of Java or in favor of C#. Means, still standing on this confusing road; and waiting for a proper guide.


Perhaps this is because the question as stated is unanswerable: there is simply no way that two complex and huge beasts can be so simply compared with one declared "better" than the other. You'll just have to make your own mind based on your own criteria (whatever that may be).

My main question here is would this thread is better off in the MD forum?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Many of Guarav's answers are more or less correct (a few aren't). The original question is "why is Java better than C#", here's my answers.

- Better JIT/performance
- More open-source friendly
- More platform options

That's about it. A lot of what's good about Java isn't about Java-the-language, but rather Java-the-platform: Java-the-platform has, in my opinion, a *lot* of advantages over C#, but that's a different type of conversation, some of which isn't technical.

The opposite:

- Real properties
- Closures

I'm not sure if I want to list delegates or not.

So which is best for *you*? Only you can answer that--different people value different things.
Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

David Newton wrote :
- Better JIT/performance
- More open-source friendly
- More platform options

That's about it. A lot of what's good about Java isn't about Java-the-language, but rather Java-the-platform: Java-the-platform has, in my opinion, a *lot* of advantages over C#, but that's a different type of conversation, some of which isn't technical.


Dear David,

I think you have not seen the link I have posted earlier from Wikipedia, a complete comparison of Java and C#. C# is also a platform Independent language and provides a platform. But, ya one and only problem i think is NON-OPEN SOURCE property of C# makes it less popular with respect to Java. I saw that and confirming that; this question has no answer, because it is just like to ask a child "Who Loves You More Mummy Or Daddy?". Means, many opinions and many answer bisecting each other but not accurate.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
but I'd still stack up a wad of commodity hardware and Java-based map/reduce against a mainframe and COBOL for lower TCO with same-order-of-magnitude performance.


Dave, it would be a good challenge and I'd be interested to see the results. It has been a couple of years for me and COBOL applications however. However, when we created OO Java versions of certain COBOL applications, the performance speed was very close (running on Solaris machines.) The longest data routines took 20+ hours for light data loads. We fooled around with Perl threads to get some COBOL routines to execute simultaneously. Client did not want any Java JRE anywhere in the system for security reasons.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18962
    
  40

Frank Bennett wrote:
Mainframe COBOL executes MILLIONS OF INSTRUCTIONS PER SECOND...that is MILLIONS in a single second. A JRE will never be able to compete with this



I think this statement is off by an order of magnitude. Modern day processors are measured in terms of gigahertz. And some processors, such as the Intel core i7 can execute up to 4 instructions per cycle. This makes even the PC gaming machine able to execute many BILLIONS of instructions per second. Obviously, a high level language (like Java) doesn't translate one to one to low level in language (like assembly), but it is not that inefficient. And I am not counting the many cores supported by modern day processors.

Henry

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18962
    
  40

Frank Bennett wrote:
but I'd still stack up a wad of commodity hardware and Java-based map/reduce against a mainframe and COBOL for lower TCO with same-order-of-magnitude performance.


Dave, it would be a good challenge and I'd be interested to see the results. It has been a couple of years for me and COBOL applications however. However, when we created OO Java versions of certain COBOL applications, the performance speed was very close (running on Solaris machines.) The longest data routines took 20+ hours for light data loads. We fooled around with Perl threads to get some COBOL routines to execute simultaneously. Client did not want any Java JRE anywhere in the system for security reasons.



I wouldn't bother wasting the time -- as there is absolutely no chance the mainframe will win. The key term (acronym) in David's statement is "TCO" ... meaning total cost of ownership. With the ridiculously high margins of mainframes, and the even higher ridiculous cost for maintenance, the cost for running a mainframe could be hundreds of times per equivalent processing power on commodity hardware.

This is why, for high processing power needs, a grid of commodity hardware is always chosen over the big box.

Henry
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11503
    
  95

Vishal Kashyap wrote:C# is also a platform Independent language

It's only truly platform independent if you count Microsoft Windows XP as a different platform to Microsoft Windows 7 and they are both different platforms from Microsoft Windows Vista ...

Try and get a copy of the Microsoft .Net CLI for any non-Microsoft platform: not going to happen. The best you can hope for is the independently created Mono and DotGNU systems. And even then you have to hope that these independent developers have implemented enough of the Microsoft .Net CLI to meet your needs; and that they have either developed a release for your platform or that you can compile it yourself on your platform; and that they have not infringed on any of Microsoft's IP (which could get them shut down).

As others have mentioned, there are some really good things about C#, and different requirements call for different tools.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why and How Java is better than C#?