Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've been writing .Net code since 2003 and so I am very comfortable with it now and have a fairly deep knowledge surrounding the .Net framework that I have built over the years, plus feel very comfortable with advanced programming concepts and programming in general.

I want to get into some game programming, but the last C++ I wrote was at a beginner-to-intermediate level around 2001-2002. I know that there is a lot of support for game development in .Net languages these days, but I also know that there are a lot of game libraries, resources and commercial products built on or around C and C++.

Would learning C++ at this stage be a practical endeavour for me, or would the amount of time required to become competent with C++ outweigh the productivity advantage I'd get from sticking with .Net?

One of my considerations is that I'm concerned about the massive and growing impact Apple is having on the tech world and the general complacency Microsoft seems to have with winning consumer and developer mindshare these days, which leaves me wondering, if I were to focus my efforts on .Net technologies (particularly in view of the fact that the Mono team was recently laid off after Novell's acquisition), am I probably severely limiting my potential future audience for any games I create?

share|improve this question

migrated from stackoverflow.com May 15 '11 at 15:30

This question came from our site for professional and enthusiast programmers.

4  
Why don't you just buy a good C++ book and see if you enjoy the language? It certainly won't hurt to try it. –  FredOverflow May 15 '11 at 15:37
5  
Thanks for the reply. I do understand the basics of C++ and don't mind it too much, but the language itself isn't what concerns me. What always takes time is learning enough of the surrounding libraries, frameworks and APIs to do things productively, rather than spending large amounts of time reinventing the wheel simply because I didn't know that the wheel existed to start with. –  Nathan Ridley May 15 '11 at 15:41
    
Somehow I believe, in next 10 years Xbox, PC and other gaming hardware will be so powerful that managed environments would be capable of rendering a few instances of a 3D game with details beyond human's eye vision. –  lukas May 15 '11 at 21:06
2  
@lukas - maybe, but maybe not. A lot of gamers priorities aren't on the absolute best graphics any more. If it doesn't attract a big enough market, it won't get the same priority in hardware or software development. One way to look at it - a Ferrari now is probably not much faster (straight line) than a Ferrari 25 years ago. And most of us don't drive a Ferrari. Hardware is already beginning to develop in directions other than pure performance - low energy, low noise, mobility and so on. And casual games have a huge market. –  Steve314 May 15 '11 at 21:19
3  
@lukas: Yes and no. Consider that now, fields such as AI have to be very restricted in some cases in order to get a decent frame rate. With advances in hardware and parallelism it doesn't mean that performance matters less, it means that we have the potential to have more sophisticated techniques that are impossible right now because of performance restrictions. Thus, what you play now may be done easily in a less performant environment but that which is yet to come may still require as much as it can get. –  Steve Evers May 15 '11 at 21:53
show 1 more comment

9 Answers 9

up vote 13 down vote accepted

I've been tackling this question a lot myself as well, and am in a similar situation when it comes to experience.

If it helps, I'll list the discussion points that I came up with and the decision that I made.


C#/XNA

Pros:

  • Multiple deployment platforms with relative ease (pc/360/phone).
  • Easier to sell games via MS' publishing platform.
  • Tooling support for C# and XNA is very good.

Cons:

  • It's a moving target (DX has gone through 2 versions in the time that XNA has gone all of its 4+). The vast majority of books and blog entries and tutorials that you read will be of date.
  • DX support is 9.0c if I recall. We're at 11 now.
  • Don't let the garbage collector confuse you, the GC on the 360/phone only does gen3 collects so you end up having to think just as much about object lifetime as you would on an unmanaged platform.

C++

Pros:

  • The abundance of existing learning material, from the sdk to books to tutorials is huge.
  • DirectX 11 support.
  • If you don't want to use DX, there's OpenGL and the various 3D graphics engines that are out there, supported, and free.
  • Performance. For AAA quality titles, it still matters.
  • Physics libraries are pretty important for some developers/games. The best 3D physics library I ever used in XNA was an unfinished port of one written in C++.
  • Integrating scripting with languages like Lua is not only possible, but can be quite easy.

Cons:

  • C++ can be complicated and frustrating.
  • Tooling isn’t very good from what I recall and hear from others.
  • You lose all of the benefits of a managed platform.

There may have been more points, but in the end I favoured taking a C++ refresher and forgoing the comfy language and platform for better learning resources and a more stable platform as well as tools and libraries.

Some things to keep in mind are that my focus is on in-depth learning of computational behaviour (Game AI) and I do think that, in maybe 5-10 years, I would want to get a job in the games industry. Also, the weighting for the point about the ease of publishing wasn't very high as I don't plan to sell anything.

share|improve this answer
    
This is a good, considered answer by @SnOrfus, and I feel much the same (not sure what was meant about the "tooling isn't very good comment") I started in C++ and only recently have moved to C#/.NET. That said, having worked in Managed DirectX 9 (the predecessor to XNA), I would also consider giving the SlimDX (open source) library a try for .NET-based DirectX development if you want DX10/DX11 support. On the flip side, you're going to find most sample code for DX or OpenGL to be in C++. You'll want to read up on the STL and probably use the Boost libraries. –  holtavolt May 15 '11 at 19:31
    
@holtavolt: Admittedly, I don't have any strong evidence or experience to back that statement. It's mostly based what I've heard from others in my research. –  Steve Evers May 15 '11 at 20:01
1  
I disagree on the performance point. For the vast majority of tasks (even in games) the performance penalty of C# is negligible. That said, I would probably still pick C++ simply because it would let me leverage the Ogre 3D library, which is about eight zillion different flavors of awesome: ogre3d.org –  Sean Edwards May 16 '11 at 12:48
1  
@Sean Edwards When an A* search in a locomotion system takes < 4-8ms, and is still considered too slow to be used in a production system, performance matters. (aigamedev.com/insider/reviews/holy-grail-locomotion) –  Steve Evers May 16 '11 at 13:36
    
there's always unsafe code for working directly with memory if real performance is needed. –  Nathan Ridley May 18 '11 at 5:17
show 3 more comments

It depends. XNA on the X-Box uses C# AFAIK, so learning that first is a good way to leverage your coding skills in the gaming domain, and then shift to a C++ framework (if need be, there may be XNA jobs available for you).

Anyway, I think it's a good idea to learn game development without learning C++ at the same time. Risk is you'll be overwhelmed.

Give XNA a try, see if you can adapt quickly to the concepts and math necessary for game programming. Once you're (sufficiently) familiar with that, try a C++ / DirectX-based engine and do some work there. (Or go to Java / OpenGL on Android.. )

That's what I'd recommend anyway. Small steps, incremental progress. Each step doesn't need to take long, but don't do it all at once.

(There are tools/utility development positions available too. Some shops might use C# for that, instead of C++ or Python. That could be a way into the hard-core C++ development world.)

Update

If the language is not the main problem, but mainly APIs/Libraries, then you need not worry as much, since C++ has very little standard libraries (iostreams & STL) and much more depends on the actual game engine (or middlewares, or low-level APIs) you choose to do your work with. If you're a graphics enthusiast, then DirectX is a good choice to learn since it's available from C# too. Then, try to write something similar in C++. The differences will be there, but it'll be a known framework.

share|improve this answer
    
I guess it's worth clarifying that I'm not looking for a game development position in the future - anything I do would be independent and funded personally. +1 for not overwhelming myself. –  Nathan Ridley May 15 '11 at 15:38
    
@Nathan Ridley: You said that you use to program C++. A refresher might not be as overwhelming as you think. –  Steve Evers May 15 '11 at 16:59
    
@SnOrfus unfortunately my C++ knowledge was at a very junior level when I stopped. –  Nathan Ridley May 15 '11 at 17:45
    
@Nathan: Ok. Most of it are pointers on ways into game development, where you can keep your C# skills. –  Macke May 16 '11 at 9:43
add comment

I have participated in C++ projects for ~20 years. I have learned a bit other languages. Mostly script languages, to make throw-away prototypes or tools. Also i have looked at Java and C# that were supposed to replace C++. Well, these did not. So i never migrated to anything else.

Supporting .NET languages is high priority for MS. So all the development tools make your life easy. Be prepared to be frustrated with C++ development tools.

C++ is very complex language that takes long time to master and contains lot of features that are unsafe (you can easily write code whose behavior is undefined). So be prepared to be frustrated with the language.

There is and will be always market need for native C++ software. So teams will be often thrown together from quite green specialists. Some of these do not like C++. Be prepared to be frustrated with code of your team members until you are powerful enough to choose them.

However when you gain skill, have good team and get the product to work, the bugs eliminated and profiled and fine tuned ... then the outcome is a gem. Others can not get anything to work at as low resource consumption and as quick. So all the Java, C#, Python etc. teams will depend on your "native", "low-level", "legacy" and other bad names library or tool.

share|improve this answer
add comment

From a utilitarian perspective, whether or not it is worth learning C++ in depth — given that you know C#, which is what I interpret “programming in .NET” as meaning — depends on just what you're going to try to do with it afterwards. What is true is that there's lots of C++ code out there already, and that a lot of that will need programmers to maintain it, extend it, and integrate it with new technologies as they are invented. The other thing that's clearly true is that you can't hope to be expert in all the libraries that C++ integrates with (the same is true of pretty much any other non-trivial language, particularly because once a library is usable by one — typically C or C++ to be fair — it is usable by many of them with only a little more work).

But the utilitarian perspective isn't the only one that matters!

Learn because it's fun. Learn because you want to know. Learn to expand your mind. Even if you decide in the end to stick with C#, knowing about the other ways to approach a problem can help tremendously.

share|improve this answer
add comment

My number one reason I have stayed away from .NET is that the platform is controlled by single company. That always scares me. Java has gotten better but is still not as open as C++. C/C++ run (almost) everywhere I think because they are open languages. The C++ tools on all platforms have gotten better over the years and the library support is amazing! I highly recommend you pick up a good book on C++ and give it a chance. C++ combined with a strong library can be powerful.

share|improve this answer
1  
You compare .NET and Java (when related to each other, I think you're relating to the platform, not the languages on the platforms) and compare that to C/C++ (which are languages - until implemented on a platform like, well, .NET). Can you clarify that up? IMHO the Java specifications are just as open as the C/C++ specs are. Even the tooling is - although I wouldn't recommend Java as game development language/platform :-). –  vstrien May 16 '11 at 13:05
    
I'm honestly quite skeptical of this argument. It's very common and quite often touted by Linux and Mac-based programmers. In reality though and in practice, it's pretty much invalid. Forgetting about Mono, which is a very mature, completely open source and cross-platform implementation of .Net and C#, Microsoft would be putting the nail in their own coffin if they started damaging developer relations by trying to stop cross platform usage of .Net. It's just not going to happen. No commercial tools are required for .Net and MS themselves give away free dev tools for .Net development. –  Nathan Ridley May 18 '11 at 5:09
add comment

It depends on what aspects of game programming you want to get into.

If you are looking to create a game engine from scratch or integrate existing 3rd party library into your own game engine, then C++ with problem be the way to go. A very large majority of game engine backends (even one that allow you to use .NET for "scripting") are built in C++.

If you are looking to just create games and not to worried/interested in building or tinkering with the game engine inself, then C# and .NET (not all version mind you) will be fine. If you want to go this route I would highly recommend the Unity Game Engine. The engine itself is built in C++ but all scripting is done through .NET (through Mono) with C#, Boo, or Unity Javascript. Right now Unity supports Mono version 2.4 or 2.6 so it supports a bit of .NET 3.5 but not all.

Hope this helps.

share|improve this answer
add comment

Do you want to work with high end graphics engines, physics engines etc? If so, you'll probably need C++.

But I believe a lot of game logic is developed using (probably in-house, maybe game-specific) scripting languages anyway. Game logic execution generally isn't a bottleneck, whereas game logic design presumably can be.

Also, it'll probably be much easier to learn the basics of how to structure a (casual) game using C#, if only because you won't have so many problems collecting media-file libraries, building them, and getting them to work together.

My advice - do some game development experiments in C#. Either learn C++ for other career-goal reasons, or put it off until later.

Also - remember that the largest games market at the moment is for casual games running on mobile phones, very often developed using Java Micro Edition or Flash.

share|improve this answer
add comment

It sounds to me as though you're assuming that the Mono team can't fork the Mono project. This often happens in these sorts of open source projects, look at what happened with mysql and mariadb

share|improve this answer
    
Honestly I'm not too sure what the outcome of the Mono layoff will be. Obviously Mono is open source so it can be forked, but Novell was paying them full time to work on it. I wonder what will happen now... –  Nathan Ridley May 15 '11 at 15:54
1  
As I understand it, Mono was stable enough for all of .NET 3.5 (and almost all of .NET 4), and for game design I can't believe that that isn't enough for you to go forward at least while you are co-learning C++. –  jcolebrand May 15 '11 at 15:57
1  
The question was really- is it worth the bother to learn C++? What sort of time investment am I looking at in order to be able to produce something of quality? –  Nathan Ridley May 15 '11 at 16:00
    
And my point was, just stay with mono. If you feel the desire to learn C++, then do so, but stay with Mono. –  jcolebrand May 15 '11 at 16:09
    
I've just been doing some research and it seems as though there are various efforts and projects (e.g. Mono XNA) and a few others I have found that promote .Net game development on OSX and even iOS. My decision is forming I think... –  Nathan Ridley May 15 '11 at 16:12
show 4 more comments

Well, if you just want to get into casual games, then XNA is ok, but then so is Flash - as Flash runs on more platforms, especially iOS. You'd probably be better off learning that instead!

But it sounds like you want to really learn things, and no 'high level' 'game development' platform will let you do that, you'll just learn which bits to plug together to make the same games everyone else makes. To really get into the guts of how things work, why and how to make things better, then you need to learn C++. The majority of games programming is done in C++, though a lot of that is now glued together using script languages (such as lua). So the high-performance bits are written low-level, and the non-speed critical parts are even-easier-than-XNA scripting.

Don't forget that, once you know the language, learning the libraries is another big step to learn. Then you'll also need to learn the concepts too.

This question should really go to Gamedev

share|improve this answer
    
Flash doesn't run on iOS, last I checked, and there were no plans to put it there. –  David Thornley May 16 '11 at 17:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.