C or C++??

This is a discussion on C or C++?? within the Game Programming forums, part of the General Programming Boards category; I got a book on c++. My question is, is it ok for me learning this for game programming?? Or ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    1

    C or C++??

    I got a book on c++. My question is, is it ok for me learning this for game programming?? Or should I wait and learn C, then move on to c++? Is C essential to game dev?

    Thanks

  2. #2
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    i am a newbie, too.
    someone told me to start with "c" to learn the basics and than move to "c++" programming. the source in c is, for my opinion, harder to learn than the source you use in "c++". i am waiting for the day on which i know enough about "c" to start in "c++". i think i will be happy using the easier spelling code in "c++".

    hey professionals, am i right? *sigh*

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    It depends, actually.

    Many recommend C then C++, but really, C++ is 95% the same as C anyway. You may want to skip C entirely, and find a book that teaches C++ without presupposing knowledge of C.

    The one advantage to doing this, you won't have to unlearn habits you may have picked up in C which are "bad" C++.

    People saying "start with C" are really saying "start with the basics" because C++ is just C with new, advanced features. And you will want to use them often -- object oriented programming is a blessing from the skies.

    Probably the best way is to learn things like this:

    1) Learn C console programming -- get used to functions, pointers, arrays, dynamic memory allocation and release (malloc() and free()). Learn how to use if, for, while, etc. Learn how to use bitwise math, and understand how integers at least are stored in memory.

    2) Learn object oriented programming -- you'll need to move up to C++ for this. Understand classes, objects, inheritance, operator overloading, copy constructors, casting constructors. USE this style of programming almost exclusively until OOP is second nature.

    3) Learn Windows programming with use of a library (MFC, OWL). Learn to do event driven programming. At first, it will seem hard, but in the end, you'll love it a million times more than linear programming.

    4) Learn the windows API.

    Now, steps 3 and 4 are optional if you want to do a true DOS game, but for the most part, you will probably want to do a full-screen windows program, being as true dos programs have many many limitations, and windows console programs have no graphics capabilities. If you followd these steps, you could easily follow with:

    5) Learn DirectX

    which would allow you to handle input, sound, and graphics easily, and in a manner that is very similar to the WinAPI which you already need to know anyway.

    *Note*: If you are an OpenGL fanatic, and are reading this, and want to make this thread degenerate into *another* DirectX vs. OpenGL thread, please exercise restraint. All the world does not need to conform to your opinions on which graphics library is better, and in this case, which library is "better" or "worse" is highly relative, and also highly application specific.
    Neither library is unilaterally better or unilaterally worse -- each have their strong points, and each of them is capable of working just fine in 97% of all applications.
    Last edited by The V.; 10-20-2001 at 04:32 PM.

  4. #4
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    DIRECTX IS BETTER THAN OPENGL!!!!!!!!!!!!

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    swop 3 and 4 around and that is an excellent speech the v.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    You can do it that way, too. The only reason I recommend it the way I did is that it's usually easier to do MFC or OWL, and either will heavily reinforce the OOP learning from step 2. Once you already have a good idea of how windows GUI programming works, it's probably easier to learn the API, versus having to learn it first.

    I am just recommending an order I think would work well -- I actually learned C, learned a little WinAPI, learned C++, OOP, then OWL, then more WinAPI.

  7. #7
    Sayeh
    Guest
    Most commercial games are written in C, not C++. Now, please don't berate me for saying this. This has come up lots of times on this board, and has been proved by numberous interviews with game companies that have been shown on television. Other members on this board (you know who you are) have posted such information.

    The reason is simple-

    -cumulative performance gains because the developer must be responsible for code quality. C allows this, C++ doesn't as much.
    -Most games don't really much on a GUI so much as a drawing engine, so all the benefits of MFC in C++ are pointless, because that really is geared towards Windows GUI API.

    I prefer C, myself, but have seen some games in C++. If you have a PS2 or a Nintendo, or whatever, one of the things to bear in mind is that most of these boxes have the lowest powered, lowest cost hardware the manufacturer can get away with. XBOX is an exception.

    Due to this, the code for games is run on lowend processors with limited RAM-- as such, the games have to be written in a non-OOP language, such as C and assembler.

    I mean, when you have a MC68000 chip with only 2MB of RAM, the game code's gotta be tight and fast, because most of RAM is used to hold graphics data.

    enjoy.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21