Skip to main content
GameDev.net gamedev.net
🔒 Locked

Java vs C# (Mono)

Started by LizardGamer Jul 24, 2011 at 3:05 AM 27 replies 10.4k views
Original Post
LizardGamer
LizardGamer
What would you find the best for Cross-platform game dev?

In what ways would you find one of these good?

What is your opinion on these 2 languages?
SimonForsman
SimonForsman

What would you find the best for Cross-platform game dev?

In what ways would you find one of these good?

What is your opinion on these 2 languages?


It really doesn't matter all that much, the main advantage C# has for game development is XNA which isn't available if you go cross platform, The quality of the crossplatform libraries and engines are pretty much the same for both languages, both runtimes (Mono and Java) have good performance these days, Personally i think Microsoft will do a better job with the actual language than Oracle will.
[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!
boogyman19946
boogyman19946
I've never really used C# and I don't know it's capabilities are, but much like Simon said, Microsoft will probably do a far better job with their product than Oracle (it seems they already are). In terms of cross-platform, I can't seem to find any evidence that Java works on the consoles, but Wikipedia suggests that C# is seeing support on the 360, PS3, and the Wii, so it definitely gets an edge.
Yo dawg, don't even trip.
LizardGamer
LizardGamer

"Cross platform" is way too vague. Which platforms are you trying to target?


Mainly Linux, Windows, Mac, Android
LizardGamer
LizardGamer
I know that Java is faster than C# (when using the VM), but Java uses more memory, and I see Java has alot more game related tools like Jmonkey, Lwjgl, jogl, ode4j, jbullet and I haven't seen too many for C# (and please don't say Xna because it only works on Windows and Xbox 360)

And that some people say C# is much easier than Java.



But I find it difficult to choose between these languages
kunos
kunos
how do you know that java is faster than c#?

To answer your question, c# / mono / opentk will take you to windows, mac, linux, android, iphone and who knows what else.
You also have to think about Visual Studio as part of c#.. the productivity boost you get just by using it is, alone, a reason to prefer c#.

But as usual, when it comes of these threads my answer is.. you cannot choose and don't have the necessary background to make a decision... throw a coin then stick with it. Both languages are perfectly capable of delivering... the bottleneck is the programmer, not the technology biggrin.gif
TheAverageUser
TheAverageUser
I don't think there is really a significant performance difference between Java and C#. I'd pick C#, but that's just a personal decision. my impression is that C# is more advanced than Java in matters of actual language features. LINQ is pretty neat, to name one. There's a lot of nice syntactic sugar. Besides that, here is a comparison between Java and C#.
ApochPiQ
ApochPiQ

This will answer your question:

Language Benchmark


The problem with language benchmarks is that, despite the extensive explanations of their methodologies and prolific disclaimers about how to interpret the results, people such as yourself will come along and pay no heed to the important facts because the shiny numbers are so much easier to misunderstand.

I doubt I could accurately communicate why this benchmark does not say what you think it says, at least not in a way that you can't already read for yourself directly on the benchmark page; so if the information there is not sufficient to explain to you your mistaken thinking, then I'm afraid I'm at a loss for how to clarify the situation here - at least, I'm not going to be able to pull it off a 4AM.

Please don't take this as a jab at you personally; the simple fact of the matter is that you lack any kind of training or background in the sorts of things that this "language benchmark" measures. The mere fact that you do not immediately recognize "language benchmark" itself to be a wholly disingenuous misnomer is a pretty strong indicator that you are not qualified to interpret its results.

I don't want to leave this off without at least trying to explain the problem, as that would just be inconsiderate; so here's my best shot:


What you are doing, by looking at these numbers, is like comparing the wealth of two people. You want to know which one is richer, right? So in order to do this, you count up all their possessions and see what they total up to.

Here's where it gets tricky. The people you are comparing are from different countries. Different centuries, even. One of them is an ancient Egyptian nobleman and one is a contemporary business executive. What numbers will you use to see who is truly the richer?

If you said "dollars" then you lose, thanks for playing.

By analogy: you want to know which language is "faster" (which is a bogus question to begin with, but I digress). So you pick a metric that is familiar: seconds. Surely everything can be timed in seconds, right? Of course! So let's do some tests with each language, count how many seconds are involved, and we have the answer, right?

The trick is that the first question is obviously broken. Egyptians didn't use dollars, so you have to find a way to make a meaningful comparison of wealth. And if you have any economics training whatsoever, you know that that is a very difficult question. Things are vastly different between ancient Egypt and Silicon Valley, and it could take a career's worth of research just to come up with a way to compare "wealth" between the two eras in any meaningful fashion.

Now, I'm sure you're asking at this point what this has to do with language benchmarks. Obviously there's no connection between this Egyptian stuff and C#, right? Wrong!

The problem is that you think that you can use seconds as a comparison; my point is that using seconds to compare one language to another is just as naive as using dollars to compare dot-com entrepreneurs with Pharaohs.


I can dig into the technical specifics of that if you really want to make your eyes bleed - but I would like to request a chance to get some sleep before I tackle that wink.gif
kunos
kunos

[quote name='kunos' timestamp='1311499095' post='4839529']
how do you know that java is faster than c#?


This will answer your question:

Language Benchmark
[/quote]



so basically you don't know. you just decided to trust these people.
that does answer my question biggrin.gif
MatthewJackson
MatthewJackson

[quote name='ApochPiQ' timestamp='1311488447' post='4839498']
"Cross platform" is way too vague. Which platforms are you trying to target?


Mainly Linux, Windows, Mac, Android
[/quote]

As I understand it, all of these platforms commonly have Java compatibility, but, with the exception of Windows, will require that additional components be installed (namely Mono) in order to run emulated .NET bytecode (I know that it's not actually emulation).

I researched something similar, but for Windows and OSX only as well as having a few other parameters, and came up with C# being incapable of transparent to the user cross-platform compatibility. In my opinion, that makes C# only appropriate in special circumstances.
SimonForsman
SimonForsman

[quote name='LizardGamer' timestamp='1311488914' post='4839500']
[quote name='ApochPiQ' timestamp='1311488447' post='4839498']
"Cross platform" is way too vague. Which platforms are you trying to target?


Mainly Linux, Windows, Mac, Android
[/quote]

As I understand it, all of these platforms commonly have Java compatibility, but, with the exception of Windows, will require that additional components be installed (namely Mono) in order to run emulated .NET bytecode (I know that it's not actually emulation).
[/quote]

its very far from emulation, Mono is a free implementation of the CLI , it works in pretty much the same way as Microsofts own implementation in .Net or Oracles JVM and it is theoretically possible(allthough given the difference in developer resources its unlikely) for Mono to become faster than Microsofts .Net.
[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!
21st Century Moose
21st Century Moose
Performance of Java vs C# doesn't come from the language, it comes from the VM. And don't forget that in a game a huge chunk of performance is going to come from your graphics hardware, and that has nothing to do with the language being used.
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
LizardGamer
LizardGamer

Performance of Java vs C# doesn't come from the language, it comes from the VM.


I understand the VM has to do with the performance and all that, and I found out that Java's VM is having a massive update to the end of this year and next year (with Java 7 and 8)


And don't forget that in a game a huge chunk of performance is going to come from your graphics hardware, and that has nothing to do with the language being used.


It depends on how well the binding is to the graphics API e.g. OpenGL or DirectX
With Java there is Jogl and Lwjgl (OpenGL)
With C# there is OpenTK (OpenGL)

(I don't care about DirectX )
21st Century Moose
21st Century Moose
It depends on how well the binding is to the graphics API e.g. OpenGL or DirectX


Yes and no. Ultimately the graphics API isn't doing the actual drawing, the hardware is. All the graphics API does is tell the hardware to draw, so all other things being equal language is of minimal relevance for this consideration. So the binding is important only in so far as it doesn't generate unnecessary overhead, but it's importance ends there.
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
way2lazy2care
way2lazy2care
I would take C# because for the majority of situations. The performance increase in either direction would be small, but the productivity increase I feel would favor C# quite a bit.
arbitus
arbitus

Mainly Linux, Windows, Mac, Android


One of these things is not like the other things (pretend rest of the song is here)

Cross platform development introduces (often times unnecessary) extra overhead and development considerations. For instance, even in Java, you have platform specific libraries to consider, you have platform implementations to consider (are the VM performances equal across all platforms), and you may even have platform difficulties to consider (does the target even support all of the library functionality).

Then you have to consider the platforms themselves. Obviously an Android app is going to have more hardware level restrictions than a desktop platform, so do you restrict yourself to only the lowest common denominator when writing your code? Do you have different implementations for each, which enhanced features on desktop platforms?

Also, you have differences in toolsets. You can write all of your Java code using the same editors, but will your build chain be the same across all platforms? Maybe you need to use a different profiler on a different platform? For sure you need an Android emulator for testing Android apps.

Different tools (and programming languages are just part of your suite of tools) work differently in different circumstances. Some are better at some things than others, some have better platform support than others, some focus on solving certain problems whereas some are general purpose, some have better library support, etc. etc. etc. Usually when people start talking about "cross platform development" (especially those who are new to programming or come from a homogenous background) they are really asking "what tool can I use to do everything?" And the only real answer is "all of them." Just like when you build a house, you use all your tools, when you want to do everything in computer software, you need to understand and use different tools for different tasks.

But you don't want to do everything. You want to do something. What is it that you want to do? You mentioned Android, so perhaps you want to build an Android app. If you want to build an Android app, why are you concerned about Windows, Linux, and Mac? These are unrelated desktop platforms, and what is best for building Android apps may not be best for building desktop applications on these platforms. The "app" model of development is generally not mainstream on desktop platforms in the same way as phones and tablets, so even if your "app" is cross platform, does it make a difference if it will only be adopted by mobile users? If not, then you have expended time and energy trying to pick a tool that was ill suited for your actual needs.

So my suggestion is that you think through a few basic questions: What do you want to make (app, desktop thick client, browser based, etc.)? What form does this software usually take (there are big differences in requirements among full desktop games, web/browser based games, and mobile games)? What are the platforms that typically support this type of software (people who primarily play AAA desktop games do so on a Windows machine, casual and browser based games are often platform agnostic using technologies like Flash, mobile apps are generally created using the specific tools for that mobile platform)? What are the tools that are typically used in the creation of this type of software (Android emulators for Android platforms, Java and associated Android libraries as the default development platform for Android vs. C# and XNA for XBOX\WinPhone 7 compatibility)?
Serapth
Serapth

[quote name='ApochPiQ' timestamp='1311488447' post='4839498']
"Cross platform" is way too vague. Which platforms are you trying to target?


Mainly Linux, Windows, Mac, Android
[/quote]


With this list of platforms, with wanting to make a cross platform game, is about the only time in the world I would actually recommend C++.


Plus, Android implements a subset of what is supported on those other platforms. I did some development last year on Android and quite frankly, it was not a pleasant experience, especially if you wan to support the plethora of devices and versions. My most frustrating experience was writing code that worked on 1.6, 2.0, 2.2 and 3.0 devices, but wouldn't run on 2.1! Oh, and the joys of Google support, which is frankly non-existant. In addition to the complete crap marketplace, the offloading of customer support onto the developer and the various undocumented "gotchas" which are far to common, it was a brutal experience. Despite all their billions of dollars, so often dealing with Google feels like amateur hour.

Another thing to keep in mind, the UI development process on Android is completely and utterly different than every other platform you just listed.As is the user experience.
Dragonion
Dragonion
"Although C# applications are intended to be economical with regard to memory and processing power requirements, the language was not intended to compete directly on performance and size with C or assembly language"

~ One of the ECMA design goals for C# ~

"Like C, Java's goals were really around being able to build relatively specific kinds of software, and we were really going for very distributed, very reliable, interacting-with-people kinds of software -- ones where things like reliability mattered a huge amount, things like security mattered a huge amount, and they all mattered enough that there was a willingness to take a performance hit for them"

~ James Gosling, inventor of the Java programming language ~


... and this pretty much sums up why you shouldn't use either for game development =)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.