Gaming Programmer Question

Harlequin

Sentinel
Joined
December 26, 2008
Messages
211
Location
Boston, MA
Please only looking for KNOWLEDGEABLE input if you are a programmer by trade or/and involved in the gaming industry. Thank you;

Want to get back into development and was thinking of learning C# or one of the other more modern languages. However from my research it seems game dev's are STILL mostly using C++.... basically my question is why and why not one of the more modern language that handles memory mgt better?
 
Joined
Dec 26, 2008
Messages
211
Location
Boston, MA
I am not in the industry, but I can tell you that this question is asked and answered literally on a daily basis on programming forums.
 
Joined
May 3, 2008
Messages
615
Please only looking for KNOWLEDGEABLE input if you are a programmer by trade or/and involved in the gaming industry. Thank you;

Want to get back into development and was thinking of learning C# or one of the other more modern languages. However from my research it seems game dev's are STILL mostly using C++…. basically my question is why and why not one of the more modern language that handles memory mgt better?

I'm not in the industry - and I'm not what you would call a programmer by trade. I do, however, know a LOT about the industry - and I'm a "casual" programmer myself.

As for your question, it depends. Are you looking for a way INTO the industry? If so - then it depends on what level of the industry. If you're looking to join a "big name" company - then C++ is most definitely a very valuable language to learn - and yes, a lot of professional game developers use it. My guess is that it's still the most common language. Also, you have to work with others - and often with licensed engines where C++ tends to be a sure bet.

Why? Because that's what they're used to - and the more experience you have, ironically, the less you're inclined to switch languages. Unless, of course, you're just doing it out of passion for learning. But for development, you go with what you know - and you're paid to develop results - not to learn the most efficient language.

If you're looking for indie/small-time/personal stuff - then I'd recommend whatever you're comfortable with, and I'm personally using C# for my projects. The language in itself is more modern and it's well documented, but the development environment known as Visual Studio is just fantastic.

If you're looking for the fastest and most efficient way to develop games - I'd say something like Unity and XNA are both very popular at the moment, and Unity is especially good in terms of cross-platform development. Unity is a game engine - and XNA is a toolset for game development. You have to complement both with actual code - and C# is a good choice.

I use XNA and C# with Visual Studio Express - and I can do pretty much anything I want to do in terms of game development with those.
 
I know that Age Of Wonders and its 2 sequels were programmed via Delphi.
"Tribal Trouble" was programmed in/with Java.
It's still possible, although not common.
 
Joined
Nov 5, 2006
Messages
21,952
Location
Old Europe
I used Delphi once (very long ago) - it was like a visual version of Pascal. Quite easy to learn - but I doubt it's a good choice today.
 
I'm a professional programmer.

The answer is rather simple: It boils down to performance. You can't really achieve the same performance in Java or C# as you can in C++. There are several reasons for this, for example:

- C# and Java both have automatic garbage collection. In C++ you can manually tell it to remove objects from memory.
- Manual allocating of memory.
- No need to run it through some sort of virtual machine, such as JVM.
- Etc.

Even if a game isn't very demanding, you still want it to run as smoothly as possible on as low specs as possible to reach the most users. However, if it's an indie project or similar, there's no real reason to use C++, as the performance gain would be negligible in such cases in my opinion.

Edit: Of course, such optimization takes additional time, so that's worth taking into consideration.
 
Last edited:
Joined
Oct 18, 2006
Messages
7,586
Location
Bergen
Dartagnan writes:
Also, you have to work with others - and often with licensed engines where C++ tends to be a sure bet.

I'd say this is one of the major reasons. It's a very rare game these days that doesn't use some kind of 3rd-party libraries / engines to create the end product. A lot of these offerings probably do not have C# or Java interfaces. C and C++ are the only ways to directly interface with their code.

Another reason that hasn't been mentioned is consoles. Most commercial games these days can't get by with only having a PC version. My understanding is that console platforms have a more modest memory footprint than a beefed-up PC. Therefore, a developer that is looking to maximize performance on limited resources is going to want complete control of memory management -- including exactly when and where memory is allocated/released.

For instance, you might want to manage your own memory heap that is customized for the object types most allocated in your game. You wouldn't rely on the runtime allocator for this service. You would allocate a huge block using malloc/new when the game starts, then slice that up into a certain number of "game objects" that your application manages.

This kind of finely grained memory management isn't possible (AFAIK) with Java or C#.

I WILL say that faster processors have made the performance hit of running interpreted/managed code negligible in a lot of cases. C# and Java can definitely be used to develop PC games than run at decent performance. It's just those big ticket, multi-platform games that still need to run as close to the processor as possible.

I do think C/C++ dominance will fade one day. It just isn't here yet.

(P.S. - I work in software, but not game development).
 
Joined
Oct 18, 2006
Messages
389
Location
North Carolina, USA
Yes, but memory leaks can occur, too.
One has to be VERY strict with allocating and freeing assigned memory.
 
Joined
Nov 5, 2006
Messages
21,952
Location
Old Europe
Yes, but memory leaks can occur, too.
One has to be VERY strict with allocating and freeing assigned memory.

Absolutely. With more freedom comes more responsibility. Sometimes gains in performance or savings in memory aren't enough to justify the extra headaches and risks that come with managing your own memory.
 
Joined
Oct 18, 2006
Messages
389
Location
North Carolina, USA
Another non-game programmer here and elkston speaks wisdom. I will also note that Garbage Collection is not a cure-all and you still need to know what you are doing with your objects and know when they are finalized and you still have to manage resources wisely. My code in C# is liberally sprinkled with using and try/finally statements to ensure proper cleanup of resources. The difference is I don't handle memory in C# like I do files now which is nice.

I have a third-party java server app that can bloat to 16 GB of memory due to poor object management. We reprogrammed specific parts using their SDK to reduce that to max 1.5 GB because they were mismanaging certain objects. 16 GB on the server was not good enough for them and it would crash and GCs started taking nearly a minute which would cause the app to stutter badly. My experience is the .NET GC is good at minimizing GC collection time compared to Java and I see less stuttering in high performance object intensive apps but I still see bloat in apps which cause problems for me. Also trying to find a leak in C# like an object kept alive unnecessarily by an event handler is a major PITA.

I'm seeing more game engines using C# like Unity and XNA so it looks like there is room for .NET at the core app and it probably speeds up initial development tremendously. Also note that Lua is showing up quite a bit in games for scripting and Skyrim is using ActionScript but those are likely tying into C code on the other side.

The question about whether to learn C# or whatever I think is different. If you are looking to be professionally hired then I think what part of the app/tool chain do you want to program against. The core engine is bound to be C or close to it for some time but developer tools are likely to migrate to C# or python I would think. 3dsMax has allowed .NET plugins for several years now. I love C# for putting together small user/developer facing tools as it really easy compared to the MFC,WTL,… C++ crap from the past.

Unless you doing system programming or embedded programming or something, C# seems to be a useful language to learn for the time being given Microsoft's mood but Java, python, php, ruby, haskell, erlang, … are all useful in there specific domains. I wouldn't be surprised to see erlang showing up on server-side MMO code for instance though I have no direct experience in that industry and sort of doubt its being used there.
 
Joined
Apr 23, 2010
Messages
688
I'm always amazed at how many programmers hang out in these boards. We're really going to have to make use of that some day.

One little correction - you can actually call into outside DLLs in .Net. I'm not sure what it is in C# but you use the Declare statement in VB.Net. Getting the variable types just right can be difficult or even impossible sometimes but most of the time it works. There used to be an actual API for using DirectX, too, but that got discontinued.
 
Joined
Aug 3, 2008
Messages
8,253
Location
Kansas City
I'm always amazed at how many programmers hang out in these boards. We're really going to have to make use of that some day.

One little correction - you can actually call into outside DLLs in .Net. I'm not sure what it is in C# but you use the Declare statement in VB.Net. Getting the variable types just right can be difficult or even impossible sometimes but most of the time it works. There used to be an actual API for using DirectX, too, but that got discontinued.

You use the extern keyword in C#.
 
Joined
Jul 9, 2010
Messages
256
Extern isn't typically enough as you also need to use DllImportAttribute on the method so it knows where to find/load/bind to the dll. I prefer Managed C++ (version 2) for creating seemless links between C/C++ code and .NET on Windows but its complicated and is only necessary if you have any complexity or need the performance boost or need a clean interop to give to customers.
 
Joined
Apr 23, 2010
Messages
688
If you can figure out C# or Java you can learn C++. It's really not that difficult once you get into it, it just has a pronounced initial learning curve. I self taught back in the late 90's when COM was big, did complex investment management apps in MFC, STL etc. All I knew prior was VB.
 
Joined
Oct 18, 2006
Messages
3,593
Location
Boston MA
You should investigate the companies likely to hire you or the ones you are interested in.

They are the ones who are going to hire you. As most developpers will report about their surroundings, they might in good faith give you advice that is limited to their surroundings, something that might get you employed if you were in the same surroundings. Which you probably are not.
 
Joined
Mar 29, 2011
Messages
6,265
I have worked on some game dev projects ( even by AAA studio ) in the past.

C++ is the only language, except for tools and plugins and such a things.

Now there is some support in Direct X for C# and in opengl for java, but that support has been dodgy at best, so you don't really have a choice.

On top of that C++ will allow you to get much better performance if programmed correctly. There are also limit within C# and java language ( things you simple cannot do ) so for game programming yes C++ is it.
 
Joined
Oct 25, 2006
Messages
6,292
For games and drivers use C++.

For business software and database frontends Delphi XE, Java, C# or VB.NET.

Delphi XE can be used for games too, but there are only a few game engines out there that work with Delphi.

Delphi made a good comeback in 2011 with the XE version.
It is very easy to learn (like VB6), fully object oriented, but you can program functional as well. It is nearly as fast as C++ and compiles to native code.

Only disadvantage: The compiler software is expensive.

Best advantage: You can program two times faster in Delphi than in any C like language. The productivity is very high. (This was my major argument - after 1 year of discussions my bosses allowed me to program in Delphi again - they prefer the Microsoft languages, because ... well it's Microsoft ;) )
 
Last edited:
Joined
Oct 18, 2006
Messages
20,013
Location
Germany
Back
Top Bottom