Sign in to follow this  
GunBlade

Why not C#

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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++.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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#...

Share this post


Link to post
Share on other sites
Quote:
I think these particular properties may allow managed code to be faster than unmanaged code in games, period.

the main inventor of c# Anders Hejlsberg is on record as saying c# IS SLOWER than c++

though c# does have other benifits over c++

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
Quote:
I think these particular properties may allow managed code to be faster than unmanaged code in games, period.

the main inventor of c# Anders Hejlsberg is on record as saying c# IS SLOWER than c++

Where? I would believe he said that generally C# is slower, but I doubt he just said "C# is slower than C++". Promit said "may allow", so he is most likely not talking about the general case. Would you argue that memory allocation in C# is slower than allocation in C++?

Share this post


Link to post
Share on other sites
The more the program language does for you, the less chance you have to customize what it is doing. sometimes managed code does the management unecisarily, but it is transparent to the coder... where as in unmanaged, it never does it unecisarily, you can code to the lowest functioning demoninator.

THe managment protocols in managed software are blanket management... they dont' change based on implementation of said algorithim. It is much harder to write highly efficient algorithms where you need lower access to the memory to make it work.

Its also a lot easier to fuck up while implementing unmanaged code, though.

I'd just use perl! it has opengl extensions availible...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this