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 heard recently an instructor mentinon that developing games was the best way to learn programming. Besides the fact that everything had to be created in code, he said you really get to fully experience and implement OOP into your programs. In other words everything you make in a game is a literal object both technically and in concept. Is it safe to make this assumption? Or are there always exceptions when learning programming?

note it was geared towards .net / xna / c# development.

share|improve this question
3  
"the fact that everything had to be created in code". What about the 3D models, textures, sounds and other resources ? You can create a game engine without them, but a complete game with very few resources, even if not impossible, will be quite the challenge. –  Nathanael Sensfelder Apr 27 '11 at 19:25
    
@Cheshire: Well, you could program those with things like Processing. I'm not saying it is very practical though. –  Anto Apr 27 '11 at 19:29
2  
@Cheshire: Yes, some people take on this challenge very directly, by creating everything procedurally. Not too common in commercial games (as far as I know), but popular just to prove that it can be done and I've seen some pretty impressive demos like that. –  FrustratedWithFormsDesigner Apr 27 '11 at 19:30
6  
I assuming this question means 'game development' rather than 'playing games' when asking about gaming? Can't quit make the intellectual leap from Call of Duty to C++... –  HorusKol Apr 27 '11 at 23:50
1  
If you want the game to be playable then you may well find that you need to compromise pure OO design in favour of speed. –  Peter Taylor May 1 '11 at 13:29
show 2 more comments

12 Answers

up vote 24 down vote accepted

Game development is some of the most challenging development that there is, in my opinion. Let's look at all the concepts one person creating a first-person shooter needs to know:

  • Graphics
    • 3d calculations
    • Speed optimizations
    • Interfacing with graphics hardware
  • The game
    • Data structures
    • File formats for saving
    • General design, or else you'll create a mess that's impossible to add features to
    • Network knowledge if the game is multiplayer
  • AI algorithms
    • Path finding
    • Battle fighting
  • Publishing
    • OS knowledge such as how installers work
    • Possibly web development for getting the word out

You see, one game can cover a lot of areas simultaneously. This makes it an excellent learning tool if you are willing to spend the time and make it good.

As for OOP, that's one pattern that works well. You can use a game as a learning tool to practise good design techniques.

To answer your question, though, it's not the only way to learn programming. Once you do become an intermediate developer, creating a game will let you touch a lot of programming concepts and levels. Besides, it's fun!

share|improve this answer
12  
You forgot one thing, a story for that game, and sometimes, the story is all that matters. –  Mahmoud Hossam Apr 27 '11 at 21:47
    
This assumes it's a 3D game. –  Adam Harte May 1 '11 at 21:43
1  
@Adam: It does, but 2d has its calculations too. I am now purposely excluding test-based RPGs ;) –  Michael K May 2 '11 at 13:05
1  
@Mohmoud The story is NEVER "all that matters". This is just as big a mistake as having a bad/missing story. There are many aspects that go into making a good game. I don't want to play a boring game, no matter how great the story is. Also most successful puzzle games don't have a story. –  Adam Harte May 2 '11 at 21:20
    
Game theory is handy too. –  VirtuosiMedia Feb 4 '12 at 7:20
show 1 more comment

If you enjoy gaming then writing games would be a good way to get in to development but I wouldn't say it was the best way. I think the best way is a CS degree course followed by a job with a software house that will invest in training and mentoring junior staff.

Apart from that admittedly rather pompous reply, yes, game development would teach you a lot of good skills I think, and if you enjoy computer games it will keep you interested in the development process. It's got to be more interesting than a lot of other simple apps you see in books.

share|improve this answer
add comment

Not to be tautological, but programming is the best way to learn programming. If you are interested in computer games, then programming games may be a great way to learn programming.

I don't care for games, but I love math, so much of my learning projects were very mathematical in nature.

The bottom line is, you need to find ways to solve problems with code, and games work for many people.

share|improve this answer
    
this is what I thought originally. But consider your absolutely new to programming. Gaming seems like an excellent tool to learn many different concepts. Michael lists some of those. To be honest I wish I would have learned OOP from a gaming perspective first. But that could have been due to the fact that it was poorly explained, or that developing business applications makes it a little more difficult to grasp the concept. It's definetly interesting to observe both arguments. –  loyalpenguin Apr 27 '11 at 19:37
    
@penguin in what way would playing Call of Duty or Halflife teach you programming? –  jwenting Apr 28 '11 at 10:21
add comment

Games programming is the best way to learn games programming. If you want to learn web development, do that, if you want to learn systems programming, do that and so on.

Game programming is challenging, and it will most likely teach you a whole lot of things (Michael noted many in his answer, and many of them are very challenging, and usable outside games as well). Creating an RPG or tycoon (or similar game) will teach you a lot about OOP design because they lend themselves very well to that paradigm. You will also be able to learn a lot about performance considerations, some hardcore mathematics for games etc., depending on the complexity of your graphics and physics.

It is a good way, and the best way to learn some things, but it is not a superior way to learn programming. No matter how many games you have programmed, it is still likely that you will have no idea about how to make an operating system. I think that most developers could still earn something by developing a game, even if they don't do that as their main discipline of programming, as long as they have the time.

share|improve this answer
add comment

It is a way to learn programming, among other ways. When you write code, you learn things. Now, is it the best way? Not so sure.

At least, the two reasons given by your teacher are not valid.

  • "everything had to be created in code": when you write a business app, you are actually writing the code. It will not be written by magic. Yes, there are helpers which allow you to use auto-generated code. No, it's not mandatory to use them. By the way, the auto-generated parts are generally the most annoying of programming (it's not by adding controls to Windows Forms control that you will learn something exciting and useful).

  • "you really get to fully experience and implement OOP into your programs": somebody has to explain me why this is valid only for games, but invalid for anything other. If you do understand OOP and want to use it, you may use it in business applications as well. If you don't get it or don't want to use it (and prefer using functional programming for example), gaming development will not force you to change.

But:

Developing games may be fun. Most of the young people like games, so they would enjoy developing a game rather than writing a business app, which will be extremely boring for the most of them. Seeing this, teachers can start to believe that actually gaming is the best way to learn programming, and then they will try to find logical explanation for that.

This being said, those teachers end by making games development as boring for young people as development of business apps. If they believe that gaming must be done in order to learn OOP etc., then they will ask their students to do the sorts of projects which are not enjoyable at all. This was one of the largest mistakes of my teachers when I was in college. They gave us very often game projects to write in Ada in console mode. No graphics. No fun. No user experience. In my whole life and my career, I never saw projects as boring as that.

share|improve this answer
4  
Games work well with OOP because it's very easy to see how every BadGuy, Weapon, PowerUp, and other items in a game can easily be an object. You get to program interactions between the objects and the see them on-screen. I think the visual part is what makes it so appealing. Business applications that have type hierarchies of ServerTaskScheduler, AbstractDataProcessor, UserQueryAgent, etc... aren't as exciting, even though they may teach the same OOP concepts as in gaming. –  FrustratedWithFormsDesigner Apr 27 '11 at 19:28
4  
@FrustratedWithFormsDesigner: maybe I just don't get it because I spent too much time developing business apps, but I don't understand why would it be more difficult to see how Customer or Product or Transaction can be objects. But I understand that it's much more enjoyable to deal with BadGuys rather than boring Transactions. –  MainMa Apr 27 '11 at 19:35
    
It has more to do about the level of abstract thinking. Some programmers get hung up on names a lot because they have no idea what to relate to. E.g. I've met some devs that have no idea what a Transaction entails. –  Spoike Apr 28 '11 at 10:49
add comment

Question: What's the best method to learn programming

Answer: The method you actually do

Ie, when learning or doing something, it doesn't matter so much what method you pick so long it's a method you actually go through with.

If gaming is something that seems really fun for you, go for it. If you find solving math problems more satisfying, start with that. There are many different kinds of programming and each require different skills so a good bet is to start with the one you find most interesting, that's probably the one you'll be working with.

... But yes, gaming is a good way to learn a pretty wide array of programming since it incorporates math, concurrency, algorithms, oop, graphics, etc etc

share|improve this answer
add comment

I'd say that the best way of learning to code is by making it fun to you. It doesn't have to be a real game, but some kind of game to you. To me, it is a game to solve some math problems developing algorithms in a way that I can solve a complex problem the fastest way possible. Be challenging my self I become a better coder at every attempt to solve a problem. The harder the problem the better.

As to learning to Code (best practices), I'd say you would have to get into a bigger challenges. Challenges the require a lot more the a single inpout/output

share|improve this answer
add comment

I've never heard of claims that playing Halflife or Call of Duty teaches you programming skills.

Programming them might, but programming something like that isn't anything a beginner should even attempt a little bit of. And especially beginners are often under the impression that they can create the next blockbuster with their non-existent programming knowledge. Tell them to try making a PacMan or Tetris clone first and they scream that that's not what they want to do and that you should 'give me zuh koduz'.

share|improve this answer
add comment

In my own experience, by writing a game (assuming you're doing this on your own/small team of developers), you're forced not only to think about the algorithmic/analytical part of programming but also the user experience and design.

In addition to that, if it's a reasonably complex game, you'll be working on this over a couple of months, and you'll realize the importance of documenting everything you do - which will later make you a better member of a team.

share|improve this answer
    
... but if you write any sort of program that interacts with a user, aren't you forced to think about the user experience and design? Are you saying that with a traditional client application you don't really have to think about those things, but gaming forces you to? And can't large desktop applications also span several months and require you to do some documentation? How does any of this apply to gaming but not other types of programming? –  Bryan Oakley Feb 4 '12 at 13:31
add comment

I think this is an excellent article giving an insight on game development.

It talks about some basic areas to focus on

  1. Passion for game development.
  2. Learning attitude.
  3. It is important to enjoy playing games.
  4. Importance of your programming skills.
share|improve this answer
add comment

Not really no. There isn't a best type of project to learn programming on. The best type of project is one that's relevant to your interests.

For example, I tried to learn programming a couple different ways, including learning to program games. It just never seemed to stick.

Then when I needed to learn how to program for what I was doing in my research? Right now I'm comfortable enough to say I know 2 languages, and am working on a third. Why? Because it was relevant to my interests. I had a reason to stick with it, a reason to learn, and more problems to try than just "Exercise 8" in the book.

This, incidentally, doesn't mean programming epidemic models is the best way to learn programming. But it was the best way for me. Find yours. It might be games, but it may very well not.

share|improve this answer
    
+1 for "the best type of project is one that's relevant to your interests". Amen. –  Bryan Oakley Feb 4 '12 at 13:32
add comment

I would agree except...

It's just as likely the first programming experience many ever had was building and programming a Lego robot (Mindstorms).

While the general term "game" can define a category so huge as to encompass almost all of programming, when used in the context of the original poster it always seems to mean "writing Doom style games".

As has been stated here before - the best way to learn programming is to have something you really want that requires a program. That is - learn programming by writing the program you want.

One of my first Windows programs was a MIDI controller program, because I really wanted a MIDI controller program, and Windows seemed the perfect fit (sliders, buttons, SDK support for MIDI, etc.). I learned a ton about Windows programming (this was back in the Win 3.1 days) from that program.

I've never been partial to game programming for the reasons mentioned here as well - I don't draw all that well, so any game I make will have poorer graphics that those of an artist. I want to learn to program, not to manage a "game building team" (laudable but totally different exercise).

In the end I quite disagree with the teacher's statement. The best way to learn programming is to write the program you really want.

-R

share|improve this answer
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.