Java vs C# - Experts points of view

Started by
28 comments, last by fraka3000 11 years, 8 months ago
I know that this question has come up hundreds of times on forums, but it is really disappointing how one can read through dozens of threads (hundreds of posts) without getting an informed, unbiased view.

I'm a beginner programmer with very basic knowledge of C# and I see that thousands of others have the same doubt as me when trying to choose between those two languages. We receive answers like "language doesn't matter, learn algorithms, design principles, oop structure, etc", or "after learning java you'll jump to C# easily".

It's not that I disagree with the above, but apart from learning the principles, structure, logic, etc, one need to get a repertoire of tools and, in fact, the language chosen may not matter that much, but the framework linked to it can take much time to be mastered. I have read through discussions about whole teams of experienced programmers resisting the change to another framework, indicating that this is a real concern among seasoned programmers. It's not just a question of adapting to syntax.

Most discussions about both languages see the same repeated statements:
- if you take on C#, you marry Windows.
- No, you don't, you'll always have mono. (nothing is said about personal experience with mone though)
- Java is "more" cross-platform.
- C# is a better structured language. (this is the only point I see which seems to be uncontested in MOST debates, but again, it's not only about the languages, but about what its environment).
- C# has better performance. (I don't know if that is true, but the possibility of using development tools like XNA and UNITY seems to have no parallel in Java. At least, from what I was able to find, JMonkey seems to be one of the best graphical engines around for use with Java, and graphics seem rather primitive)
- Others just talk about very specific details, like GC efficiency, etc.

Synthesizing, much of what is said seem like myths, uninformed points of view, fanboy talk or biased propaganda. I've even read a recent article which presumed itself very scientifically focused stating that C# has already had it best moment, but would soon fall into oblivion.
To guide those that are beginning and that, differently from expert programmers, are concerned with what will continue to be available in 3 or 4 years from now, when they finally get productive, what do you consider to be the future of C# and Java? What is real about C# portability? What does Android java code translation, Mono, ISO standardization really mean in terms of tendencies? What about performance and graphics? Is there any engine like Unity for Java use? Will it ever be? What about future development? Some say that Java has been slower than C# in that aspect, others say that new languages based on the JVM make Java environment more worth learning.

I would like to listen to informed point of views. Analysis by those that really know about what they are talking about, not fanboy talks and propaganda. This would be very useful, not only for me, but for thousands of others that are reading through the multiple forum threads which only bring further confusion.
Advertisement
Trying to be as un-flame-war like as possible:


Synthesizing, much of what is said seem like myths, uninformed points of view, fanboy talk or biased propaganda.


This is largely true, though your bullet points are largely correct.


what do you consider to be the future of C# and Java?


Java has been effectively abandoned, and is largely crippled by its lack of good generic and functional programming support.
C# is starting to show its age, where it's difficult to improve upon it more.
I suspect that both will remain the top two most used general purpose programming languages in 3-4 years, though their relative popularity will decrease; Java's faster than C#.


What is real about C# portability?


C# can be ported and it has gotten a lot better due to mobile platform motivations, but the cutting edge and best support will for the foreseeable future be on windows. That said, beginners care about portability WAY more than they should.


As for the other questions, they're vague or outside of what I can speak to. C# is fast enough, and generally, so is Java. Java has worse support for games in general, and I expect that trend to continue.
Because I'm a bit bored:

First of all, one of the core abilities a good programmer must possess is being able to take information on a subject, potentially incomplete or misleading, and act on it. Hamstringing yourself by agonizing over every decision will get you no where. The fact of the matter is, these guys:

We receive answers like "language doesn't matter, learn algorithms, design principles, oop structure, etc", or "after learning java you'll jump to C# easily"[/quote]

are pretty much spot on. You're not going get an informed, unbiased view by talking to other people; you can only get that from looking at the evidence yourself and trying both to give them a fair comparison. Your emphasis on framework over language is irrelevant in this regard; the same tenets apply.

With that being said, I can give you a (in my opinion) fairly informed (though certainly not unbiased) view of the State of the Union, as it were, in managed development.

Portability: Both Java and C# share a mostly equivalent amount of "portability points" in the language ranking wars. C# runs on Windows, Xbox, and Windows Phone, via .NET and on a huge plethora of platforms via Mono, including some of the other game consoles, and even on embedded systems. Similarly, Java runs on mostly the same set, with a few differences such as Android instead of WinPhone (embedded systems for Java are not unheard of either.)

From personal experience regarding Mono, it works just fine. I've worked on the Mono runtime, and while it's admittedly not as good as the Microsoft one (which is developed and maintained by some of the best engineers in the business), it has some nice bits that aren't even available in .NET (such as support for SSE intrinsics). I happen to think the code generation is quite good too cool.png

Language: As you've said, this one is mostly uncontested by those who take even a remotely unbiased view of things. Java and C# were very similar languages when C# first launched; in the intervening decade however, C# has continued to grow and implement new features, whereas Java has mostly stagnated. Once you've used some of the new features such as lambdas, dynamic typing, expression trees, or the asynchronous programming support, it'll be painful to go back to a language that does not have them.

Performance: You're not going to get graphs and charts of performance because you can't compare the performance of something so abstract as a language, or even of a framework as a whole. You can only benchmark specific tasks and processes within said constraints, and you can find such comparisons all over the place if you look. On the whole, it wouldn't surprise me if equivalent C# programs ran faster on average, but I'd say that's more because C# provides a greater range of language features that allow you to implement the same algorithms with less overhead. For example, Java has no concept of value types. C# can make use of these to avoid allocations in tight loops, reducing GC pressure.

Platform: Just as a Windows user, I have to say that I absolutely despise Java as a runtime platform. The installer tries to install random toolbars, the updater runs regardless of whether you disable it in the settings, and the thing is just slow and bulky and seems to eat way more cycles than it should. Saying nothing about its viability from a programmer's perspective, even as an end user I don't want it on my machine, and in fact have explicitly uninstalled it to prevent these sort of issues. The .NET framework, on the other hand, seems to stay out of my way. It has an unfair advantage of course, in that it comes built into Windows and gets updates quietly and painlessly through Windows Update, but as an end user I only care about results.

Game Development: You can do game development in any language and on any platform. People have proven that countless times over the years. How easy that is going to be, however, is a completely different question. C# seems to have growing support for game development, from engines like Unity to platforms like XNA or the new Playstation Vita SDK. I've yet to see similar excitement over anything from the Java end, apart from frameworks for mobile Android development. In the end, it's the community of users that is going to most affect your development experience, since there will be a greater amount of information to draw from to help you out. From that perspective, it's hard to beat the XNA community, which has tons of people using it, resulting in forum posts, books, and tons of middleware libraries scattered about. If you're looking for a personal perspective, I maintain an open source C# game development library called SlimDX. I happen to think it's pretty nifty.

In the Future: You won't go wrong from a career perspective learning either language. Companies are currently using both of them, which means even 5 to 10 years down the road there will be a demand for them, if only to help maintain current products. With that said, I'd place my money on Microsoft over Oracle, who recently acquired Java from their purchase of Sun and seem bent on driving it into the ground by suing people and pissing off prominent open source projects. On the other hand, Microsoft gives support to the Mono team on various bits of the project, and have legally bound themselves not to use any of their patents against them by putting them under their Community Promise program.

So that's the story, in a nutshell. I personally work at a AAA game studio, and I've done C# work on tools there. I'm sure there exist similar positions in other companies that use Java instead, though I don't know anyone who does and have yet to see positions advertised as such. I think it's clear which one I favor, though as I've tried to emphasize, you can't go wrong learning either. The more knowledge you acquire, the more versatile developer you will be, and nobody is ever going to deride you for that.
Mike Popoloski | Journal | SlimDX
Ultimately, Java or C# or C++ do not matter. You really should consider programming languages as musical instruments, and you use them to play your music. Some instruments work better for certain types of music. But just like any other good musicians, a programmer must learn how to play not just one instrument, but several. Depending on what music he wants to play, what mood he wants to convey, he picks up the right instrument and play it like a maestro.

Since you are a beginner, pick one. Java or C# really does not matter. C# has XNA for games. Java, on the other hand, has plenty of 3rd party libraries, but also allows you to make games for Android. Pick your platform (XNA or mobile), then start learning.

Ultimately, Java or C# or C++ do not matter. You really should consider programming languages as musical instruments, and you use them to play your music. Some instruments work better for certain types of music. But just like any other good musicians, a programmer must learn how to play not just one instrument, but several. Depending on what music he wants to play, what mood he wants to convey, he picks up the right instrument and play it like a maestro.


It seems like musicians have a speciality though like Yo-Yo Ma.


Since you are a beginner, pick one. Java or C# really does not matter. C# has XNA for games. Java, on the other hand, has plenty of 3rd party libraries, but also allows you to make games for Android. Pick your platform (XNA or mobile), then start learning.
[/quote]

Picking one makes sense, but I think the decision matters and depending on the person could see them deciding to focus on C# or Java. If I were forced to pick between those two I think I'd pick C#. The performance of this compression library on different languages is kind of interesting.

[quote name='alnite' timestamp='1342634973' post='4960580']
Ultimately, Java or C# or C++ do not matter. You really should consider programming languages as musical instruments, and you use them to play your music. Some instruments work better for certain types of music. But just like any other good musicians, a programmer must learn how to play not just one instrument, but several. Depending on what music he wants to play, what mood he wants to convey, he picks up the right instrument and play it like a maestro.


It seems like musicians have a speciality though like Yo-Yo Ma.
[/quote]

Of course, just as there are programmers who only code in C++, ASM, Cobol, Java and nothing else. It's a matter of preference. But even Yo-Yo Ma, I'm pretty sure, has played other instruments before settling on the cello.




Since you are a beginner, pick one. Java or C# really does not matter. C# has XNA for games. Java, on the other hand, has plenty of 3rd party libraries, but also allows you to make games for Android. Pick your platform (XNA or mobile), then start learning.
[/quote]

Picking one makes sense, but I think the decision matters and depending on the person could see them deciding to focus on C# or Java. If I were forced to pick between those two I think I'd pick C#. The performance of this compression library on different languages is kind of interesting.
[/quote]

At this early stage, any performance benchmark doesn't matter. Why is he going to do now, write an algorithm computing 1 billion data points for secret military operations in Nevada? Think about it in utility sense. Java and C# are probably two languages that are the closest to one another in term of the syntax. The main differences between the two of them are the platforms they are typically used for. Now the question becomes which platform that the OP is most comfortable in. Choosing one does not mean that he's stuck at that for the rest of his life. Choosing C# does not mean "Oh no, Windows forever! Apple is getting popular! I can't switch anymore!" Choosing Java does not make you are a slave to JVMs. He can be learning C# now and switch to Java 2 years later, or vice versa. Can't you see how trivial choosing a language is, especially between C# and Java?

[quote name='alnite' timestamp='1342634973' post='4960580']
Ultimately, Java or C# or C++ do not matter. You really should consider programming languages as musical instruments, and you use them to play your music. Some instruments work better for certain types of music. But just like any other good musicians, a programmer must learn how to play not just one instrument, but several. Depending on what music he wants to play, what mood he wants to convey, he picks up the right instrument and play it like a maestro.


It seems like musicians have a speciality though like Yo-Yo Ma.
[/quote]

I think it was a bad analogy, I'd look at it more like tools in general, a carpenter won't use a hammer to divide a board in 2 parts, he'll use the saw (And if you see a carpenter trying to bang a nail in with a saw, well... either he is a programmer who thinks one tool is all you need or he is insane)
[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 think it was a bad analogy, I'd look at it more like tools in general, a carpenter won't use a hammer to divide a board in 2 parts, he'll use the saw (And if you see a carpenter trying to bang a nail in with a saw, well... either he is a programmer who thinks one tool is all you need or he is insane)


I thought of using that analogy, but I think it's slightly inaccurate. You can't properly cut a board with a hammer, but any programming language can be used to make almost all sorts of applications. Both Java and C# can be used to make games. They both can accomplish the same thing. So I avoid using the tools analogy, as I don't want to imply that different languages are used for different things. Other programming languages might fall into that category, such as Ruby/PHP/Javascript for web development, but at least, not these two.

We receive answers like "language doesn't matter, learn algorithms, design principles, oop structure, etc", or "after learning java you'll jump to C# easily".

Like others said before, spot on. The language difference of C# and Java is trivial.

My advise is: start with one and if you feel comfortable with it, go to the other. After that, make applications with both languages.

Looking at other "beginner" programmers, the jump from your first language to the second is never easy. I think it's actually very frustrating but it is an important step to make. You'll learn a new Framework with different tools and implementation for the same job. You will see first hand the difference between design principles and their pros and cons. You will make jumps to different languages, frameworks and toolsets in your life as a programmer. Don't choose between the two languages, chances are, with so popular languages like java and c#, that later on you'd have to make an application in the other language anyways. And if not, your third jump will be easier. My advice is that after C# and/or java you move on to C++. So you will learn what the JRE and the .Net Runtime Engine are hiding from you.


Java's faster than C#.

Nope.
In Windows, the .Net Framework is closer tied to the Operating System. A Windows Computer should generally execute a C# Program faster than a Java Program. Especially Window programming has less overhead for its operations in C#.
Now to make things more complex, Java has a badass runtime optimisation. Compare the calculation times of a simple algorithm like Selection sort, after the third run or so your algorithm will run at least *2 faster.
I saw benchmarks on Linux machines, Java was there a bit faster than C# Mono. On a Windows computer, my money would be on C# for most applications.


...

can only subscribe to what you said, very good posting

Final note on C# VS Java...
if your task is to create a Window in a Microsoft enviroment, take C#. There is the greatest strength of .Net / the biggest weakness of the Java Framework.
For any other task your choice depends on the job and the enviroment.
Project: Project
Setting fire to these damn cows one entry at a time!

Telastyn, on 18 July 2012 - 11:03 AM, said:

Java's faster than C#.


This is taken out of context. If you re-read, you'll see that I said that Java's relative popularity will decrease faster than C#'s.


Nope.
In Windows, the .Net Framework is closer tied to the Operating System. A Windows Computer should generally execute a C# Program faster than a Java Program. Especially Window programming has less overhead for its operations in C#.
[/quote]


This is entirely incorrect. The .NET windowing API is closer to windows, meaning less adaptation overhead (maybe). That's the standard library, not the runtime. Java could've made (essentially) the same windowing API to get the same level of overhead.


Now to make things more complex, Java has a badass runtime optimisation. Compare the calculation times of a simple algorithm like Selection sort, after the third run or so your algorithm will run at least *2 faster.
I saw benchmarks on Linux machines, Java was there a bit faster than C# Mono. On a Windows computer, my money would be on C# for most applications.
[/quote]

.NET has the same sort of runtime optimizations (except on system types, which are pre-compiled in Microsoft's implementation).


Quit spreading misinformation.

This topic is closed to new replies.

Advertisement