Why not C#

Started by
11 comments, last by Ultimape 17 years, 4 months ago
I was wondering why everyone is using C++ for developing games, rather then using C#, which is (for me) a much easier programming language to use. Is there a drastic difference in performance?
Advertisement
There a number of factors:
- There's a much larger base of C++ code and libaries for game development than C#
- C# won't run on PS3, Wii, DS, PSP or Simbian, making it undesirable for many commerical projects
- A majority of industry experience is in C++, not C#, so there's a fair amount of inertia.
- There a percieved performance benefit to C++
- Traditionally, garbage collected languages have been seen as unsuitable for console development
This topic has been discussed ad nauseum on these forums. Suffice it to say that the main reason (at least for professionals) is the amount of code they already have in C++ and the ubiquitousness of C++ compilers. C# is portable to Linux and Mac, but if big studios want to target consoles other than the Xbox, C++ is more portable.

Frankly, if C# is working for you, why question it? Rather, look on it as an advatage indie developers have: they are more free from pragmatic issues to choose their tools.
So supposed I wasn't planning on coding for a console, is there a reason for me not to use C# for pure Windows graphics programming?
How much performance difference is there?
If used correctly there should be none to very little performance penalty (the highest I have heard is 10 % overhead). Of course if not used properly it will be very inefficient, just like C++ would.

There are many reasons to stay with C++, many platforms is close to impossible to program with C# (PS2, PS3, XBox, Wii, GC, DS, PSP, etc.) Current game developers are very experienced in C++ and may therefore produce higher-quality C++ code than they would produce C# code. Lack of libraries for C#, for example OpenGL is quite tedious to use with C#, and most commercial game engines (GameBryo, Renderware (EA), etc. ) Also many companies have internal code bases written in C++.
C# is *way* easier to program in. Trust me on this one... I just converted our game from C# and C++ and it was not fun at all going back to stone age C++.

HOWEVER: we pretty much were required to go back to C++ because the publisher (*cough* RealArcade *cough*) told us nobody was going to download 50+ megabytes of DX9 and the .NET redist.
Quote:Original post by CTar
If used correctly there should be none to very little performance penalty (the highest I have heard is 10 % overhead). Of course if not used properly it will be very inefficient, just like C++ would.
Emphasis mine.

I want to point out, though, that C# and CLR are not necessarily slower. It's not a case of "well it's always going to be a little slower, but that's ok." Managed code has a number of interesting performance properties which are difficult or impossible to achieve from unmanaged (short of implementing the managed environment). Leveraged properly, I think these particular properties may allow managed code to be faster than unmanaged code in games, period.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
i would have thought at this stage all windows computers have .net on them via windows update.
--------------------------------Dr Cox: "People are ***tard coated ***tards with ***tard filling."
Quote:Original post by Riviera Kid
i would have thought at this stage all windows computers have .net on them via windows update.


if i remember correctly the automatic update thingy isn't activated by default on a fresh install in windows XP, and then there is users of older microsoft systems such as win2k, win9x/ME, etc.

+ the simple fact that a very large number of computer users are 100% clueless.

.Net simply isn't installed on all computers and probably wont be for a few years (i assume it is installed in vista by default),

The performance of a managed language will probably always be slightly behind unmanaged once, the difference however is very small and generally negligable. especially since both .Net and Java allows you to use unmanaged and/or native code if its really necessary.

more importantly though is that since using a managed language can shorten development time you're likely to be able to spend alot more time optimizing algoritms.

if some part of your game turns out to be too slow (after you've optimized the algoritms used) you can always rewrite that part in for example c++ to see if you can get a performance boost that way.

Also: everyone isn't using C++ exclusivly, Civilization 4 uses python quite extensivly for example. The key to success is to use the best tool for the job. if you're about to write hardware drivers, or an OS kernel you really should use an unmanaged native language for most other projects however the "best" tool is generally the one you got the most experience with.
[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 must say it's interesting to see that the big reason most of you pointed out is that most companies have a C++ base code that they don't wish to rewrite their code, and another reason is the size of the .NET Framework... but no real performance issue. Given that C# is a hell of a lot more comfortable than C++, it seems weird people aren't going for it more.
Anyway, I'm at a turn point where I must decide for me and my co-workers if our next project (Which is big on OpenGL and performance) will be implemented in C++ as we always did, or if we are going to make the change to C#...

This topic is closed to new replies.

Advertisement