Game Development Community

C# vs. C++ for Game Programming

by Ryan Zec · in General Discussion · 01/13/2009 (8:13 am) · 6 replies

I know this has probably been argued to death but I am just starting to get back interested in want to learn game programming again(been doing a lot of web development) so I am not sure if the agreeument has changed at all. A few years ago, that main thing people said against C# was the speed lost you occur for using it and the requirement on the .NET framework(or Mono Runtime libraries in using Mono).

For the runtime requirements:
Now from what I understand, Window updater included updates to the .NET Framework and basically Microsoft is integrating the .NET framework into all of their applications so if the requirement on the .NET Framework really that big of a deal anymore?

For the speed degrade:
How big is this really? I am not looking to build the next Unreal Engine or a game engine that will power the next PC version of GTA, I would be happy with a game engine that would be able to produce graphics like we would have seen in the Mythos game if it was ever finished(for screen shots, take a look here: http://media.pc.ign.com/media/869/869458/imgs_1.html). Now I know I am going to have to battle my technical skills to get something like that and I improve my skill but I don't want to have to battle the language(that is something I cannot improve). So are those quality of graphics possible with a complete C# Game Engine(and possible use of C++/ASM .dll files for stuff like math and physics and what not) while still getting a good frame rate? Also from what I hear (correct me if I am wrong) more and more code for graphics are being pushed to the graphics card itself so that seems like it would also help with the speed issue. Also is using Mono/Tao Framework vs. .NET/XNA add even more to the performance loss to the equation?

Another thing I am also curious about is portability. Now I know if I use C# with .NET and XNA, I will be limited to Windows/Xbox 360. I also know that if I used Mono/Tao Framework instead, that should work on Windows/Linux/MacOS. Do you think that any of these technologies are going to become compatible with PS3/Wii/Future Consoles because if there is no chance that C# with .NET/XNA or Mono/Tao Framework will work on consoles(besides .NET/XNA working on Xbox 360) that would also be something for me to consider as I except all platform and console to continue to support C++ for a while.
Answers to these questions or links to articles that are recent(no older than 6 months) that answer these questions would be great. Thanks.

#1
01/13/2009 (3:10 pm)
If your going to learn game programming, do NOT use c or c++. There is so many errors, and you will spend SO MUCH time finding them & correcting them. And they are constant. I recommend you look into a different language.
#2
01/13/2009 (3:33 pm)
Ryan - There is a lot more that makes up a game engine than just rendering, you've got to consider physics, model formats, sound, AI, networking, input (keyboard, mouse, etc) and a load of other stuff i think I read somewhere that TGE contains over 500,000 lines of code, probably more with TGEA... that's a hell of a lot of work to get an engine working.

So really the first question is to ask yourself why you want to write a game engine and not use/modify one that's already written? i.e. Torque or even just a graphics rendering library i.e. Ogre. If you're just after writing a game then start from a base and change that.

If you're looking at it as a way to gain experience to work in the game industry then you'll probably want to stick with C++ as the majority of major game engines are written using that.

There is nothing to say you can't write a game engine using C# there are engines out there written in C# for example TorqueX and I believe Unity, it's not as fast as C++ but it's simpler to use as a language.
#3
01/13/2009 (4:50 pm)
You also need to think of a few other things.

Cross-platforming for C# is really poor. It can't be loaded onto PS3 or Wii. It can be used on Linux+Mac with a modification, but it will slow it down even more than before.

XNA is a community that uses C# 90% of the time, so you might get some help there more then you will here on that language.

I personally suggest using C++. For it is used much more often, and you will find more frameworks and more features than C#. I am not saying C# isn't a great language, but I do not believe C# is going to surpass C++ for a few years, and most game engines use C++.
#4
01/15/2009 (10:32 am)
"but I do not believe C# is going to surpass C++ for a few years"

That to me says you think it will surpass C++ after a few years.

Also I know that Garage Games has built an engine completely in C#(Torque X I believe) which I assume is the equivalent of either the Torque or Torque Advance(if someone know that would be great). Does anyone have benchmarks to see what kind of performance loss there is in the C# version?

Well I figured I would ask here because this is neither a C++ forum or a C# forum as if I asking in a C++ or C# forum, my guess is that I will get more replies in favor of the language that board is dedicated to but I will try and see what i get.
#5
01/15/2009 (10:43 am)
"There is nothing to say you can't write a game engine using C# there are engines out there written in C# for example TorqueX and I believe Unity, it's not as fast as C++ but it's simpler to use as a language."

I also did some checking and the core engien on Unity is in C++, it just allows C# for scripting(which it uses Mono instead of .NET)
#6
01/26/2009 (10:40 am)
Also does anyone know how long Torque X took to code compared to TGE just to see what kind of time improvement they say with using c#?