views:

688

answers:

10

I'm a hobbyist programmer with a fair grasp of Python and I'm currently learning C. Recently I was talking to a colleague who also wants to learn to program. In his case, he wants to learn C++ as a path to Windows game programming using DirectX. Personally, I feel diving straight into C++ as your first language is a bit much - it's hard enough keeping motivated in an easier language, and I think it's better to learn another language to get your head round most of the basic concepts, then go into something like C++.

I found Python worked well as my first language as I'm more interested in network and web programming on Linux/Unix platforms, but for someone mainly interested in Windows game programming I was thinking C# might be a better choice as he could learn using Visual C# Express Edition and XNA, then switch over to Visual C++ when he's ready to start learning C++ and therefore already be in a familiar environment. I think memory management is a lot to take in, and C# at least handles that so he can put that off till he starts learning C++.

What do others think of C++ as a first programming language for this kind of application? Should I recommend he go for C# instead?

+13  A: 

C++ should be fine. I think he is best off learning about memory management, pointers, etc. BEFORE jumping up to C# as he will understand how the program is working better. Otherwise, he will just see memory as being magic and the garbage collector will have no real meaning. It's always good to have a solid understanding of underlying languages (C, C++, Assembly, etc.) to produce the best code.

mrnye
To wit, if all you want is a good grounding in the basics, go with C. C++ has a lot of extra overhead and stuff to learn. C is very nearly a thin layer over assembly, sticking with just what you need to get the job done.
Matthew Scharley
I wouldn't agree on that : making game is a lot about high level concepts being implemented in low level concepts. C++ is more suited in this case because you want to actually work on the game (coding in high level) but have the choice to dive in the details to optimize some critical runtime parts (coding in low level). Using only C will make you learn a lot about programming but will only hinder you in learning GAME programming. If that's the real goal, having high level language features is important. And overhead isn't noticable in thoses cases. If it is, you can always optimize bottlenecks
Klaim
In some ways the most difficult part of using C++ is understanding which subset of the language makes sense for you. I feel that its easier to use c when learning memory management, pointers, and data structures... doing so limits the distractions.
Dan O
@Matthew, C is not the right choice. C++ allows you to delve into pointers/memory management if required but also gives you built-in object oriented concepts to help manage complexity. In situations requiring high performance and a need for powerful abstractions (ie games), C++ is a much better choice than C.
Ash
Perhaps I misunderstood mmye, but it seemed like he was advocating learning C++ to teach some basic computer science, then using C# for the actual game.
Matthew Scharley
I wasn't advocating any language to use in the actual game Matt. I was simply stating that he should learn the underlying concepts before learning about the high level design. Learn how pointers work, basic OO design, classes, memory management, etc (stuff that C++ does explicitly, but C# tries to hide). By having this foundation it will make the person a better coder at a higher level (in terms of optimization/debugging/everything). Languages are irrelevant mostly, although knowing the ins and outs of the language of your choice always helps. But if I was to suggest, I'd say go with C++
mrnye
+7  A: 

C++ is the main language used for most "serious" gaming titles. If programming for a major gaming studio then he needs to know the dirty little bits of C++.

Starting out with C++ might be a bit much for a complete novice. I would recommend C as a great starting point. You get familiar with the concepts of memory management and the other low level stuff before adding the complexity of C++.

Since C# is managed code, he would not be gaining the insights of the low level memory management. That will not serve him well when having to deal with C++. In this case, starting closer to the metal will help him in the long run.

Craig
+6  A: 

C++ game programming is great. But unless you like total pain while you are learning to program, you might look at starting with XNA. This will allow you to work on the game content and logic instead of fighting with your engine code.

Now if you like pain go the DirectX and C++ route to start with.

Matthew Whited
+2  A: 

Something you have to consider is existing SDK's, you probably don't want to program everything yourself. For example, there are pretty good 3D engines with different types of licencing that may suit you well.

So you should check outthe existing libraries and SDK's and the few languages you want to stick with together at the same time. Adapting to C++ or C# is not that difficult, the former is more strict and more demanding whereas it gives you more extensive control on memory, the latter allows you to focus on the main development area but takes the memory management in charge (mostly), which means you could have real-time issues.

At the end of the day, what help you can get to build your application will invariably outweight the small differences between those OO languages (to some extent).

There are lots of game engines, most are listed on this page. Of particular interest are, in the free world:

Non-free packages include Unity, and others.

If you do not want any of those engines, there are still very good libraries like Qt for C++, that allows scripting - though not directly Python, you would have to embed it yourself - and others for C#, but the listing could get quite lengthy.

RedGlyph
+3  A: 

Python is good at game programming. See i-want-to-learn-game-development-which-language-should-i-use. Consider learning Pygame.

Pygame is a set of Python modules designed for writing games. Pygame adds functionality on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language. Pygame is highly portable and runs on nearly every platform and operating system. Pygame itself has been downloaded millions of times, and has had millions of visits to its website.

gimel
+3  A: 

If he wants to get into the industry, then knowing C++ is vital, as the majority of game engines use C++. (I also developer should at some point lean C or C++)
However, if he wants to write games (as in, finish writing a game) then C++ may not be the way to go. It is very complex and has a lot of pitfalls that make it a slow language to develop in. It is not just the memory management, but things like the horrible stl related compile errors etc that make it very hard to get anything done when first trying to program.
Looking at something like C# or Python would be a better option, as they are far less complex languages and each have some good game library's.

If he decides that C++ is the right way to go, then I would recommend at least a rendering library. Something like Ogre3D at the very least. The reason for this is covered in this article Write games not engines. While writing (or trying to write) an engine from a base API is going to be a good experience, it is unlikely that the game will get finished.

Yacoby
+5  A: 

I think it is better to thoroughly learn a language such as Java or C# before taking on C++. The reason I say this is because you can easily get bogged down in the details and intricacies of C++.

I struggled with C++ on and off (as a hobby) for a few years, then at Uni I was taught Java, stopped doing any C++, got a job doing Java for a couple of years, then moved into C++ dev. I picked everything up very quickly because I already knew what patterns and concepts I wanted to apply and it was just a matter of learning the syntax and weirdnesses and getting used to pointers again. I just had to learn HOW and not WHY. Taking on C++ as a first major language is learning HOW and WHY at the same time and it can be very confusing!

XNA is a good suggestion.

Sam
Exactly my thoughts. I learned Python first and it got me used to many of the fundamental concepts behind programming. Now I'm learning C it's a lot easier to pick those up than it would have been because I just have to get used to different syntax for some of the basics, and a few additions such as pointers.I think it's more important to get someone writing code at all, and C# and XNA would make that a lot easier while being less likely to make them lose hope at how much work they have to do. There's always time to learn C++ later once the fundamentals of programming are nailed down.
mattbd
Agreed. Too many concepts, too little space to breath and innovate. Unless you're atrociously focused, learning without innovating is impossible. Throughout my learning process I learnt a variety of languages of many paradigms. C++ was always the one in which I felt I learning the least because I getting so bogged down in details unrelated to the thing I was actually trying to learn. Coming from other languages and familiar with all other aspects of games development aside from optimisation, C++ was simply a milestone to be achieved rather than a brick wall.
Rushyo
A: 

I would prefer XNA and C# for a quick and painless introduction.I would use C++, and a library like DirectX, for game programming after having some experience on the topic.Most of the most successful games have written in C++.

DarkFire21
+1  A: 

Typically, people run out of steam before completing their first game. Therefore, unless your friend has a track record of being doggedly determined, I'd recommend the most high-level option available. If you are choosing between C++ and C#, that'd be C#.

Adam Kane
Really. Writing an Asteroids clone in Python is a pretty big project. Rewriting your Python Asteroids clone from the ground up in C++ isn't.
Robert Rossney
A: 

If your goal is to have fun, and actually finish games yourself (or in small teams) that are relatively small in scope, then I say C# and XNA.

If your goal is to work in the industry, on super big budget games with giant teams... Then C++...

dicroce