Like Tree5Likes

C or C++ for games

This is a discussion on C or C++ for games within the Game Programming forums, part of the General Programming Boards category; Hello. My name is Aaron and I want to start working on games. The only problem I am on is ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Location
    US
    Posts
    6

    C or C++ for games

    Hello. My name is Aaron and I want to start working on games.

    The only problem I am on is what language to use when making my game. Should I use C or C++?

    Thanks
    Aaron

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Litarded View Post
    Hello. My name is Aaron and I want to start working on games.

    The only problem I am on is what language to use when making my game. Should I use C or C++?

    Thanks
    Aaron
    It doesn't really matter.
    C++ makes it easier in some cases. (In that logic, C# would possibly be even better(..used with XNA or something similar)).

    but (though many would disagree)...There aren't good reasons to choose C if you are just wondering which to learn.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Registered User
    Join Date
    Aug 2011
    Location
    US
    Posts
    6
    I know both for programming. Just not game programming with OpenGL.

    I know C# using the XNA, but it's slow when making a game.

  4. #4
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Litarded View Post
    I know both for programming. Just not game programming with OpenGL.

    I know C# using the XNA, but it's slow when making a game.
    If you find using C# and XNA slow, you'd find C much more slow.

    I can suggest the way I'm learning, by learning OpenGL and at the same time building a C++ wrapper around it to make things less cumbersome.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  5. #5
    Registered User
    Join Date
    Aug 2011
    Location
    US
    Posts
    6
    Yeah that's true.

    But XNA itself is a slow library and should only be used for X-Box and W7 Phones. C is not as slow.

    Thanks
    Aaron
    Last edited by Litarded; 08-28-2011 at 05:18 PM.

  6. #6
    Registered User BradyW's Avatar
    Join Date
    Aug 2011
    Location
    Maryland, USA
    Posts
    5
    I'm learning with Litarded and I've always heard that C is much faster than C# since it doesn't contain unnecessary language constructs and isn't OOP.

  7. #7
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Litarded
    But XNA itself is a slow library and should only be used for X-Box and W7 Phones. C is not as slow.
    Quote Originally Posted by BradyW View Post
    I'm learning with Litarded and I've always heard that C is much faster than C# since it doesn't contain unnecessary language constructs and isn't OOP.
    Some constructs aren't unnecessary...especially for something as complex as Game Development (If they aren't there, you've to make it yourself...as is often the case in C).

    Then choose C++ as the middle ground. (It is .. arguably..as fast as C..only uses more memory..(but that isn't much nowadays)).
    The real merit of C++ is the Standard Library.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Litarded View Post
    But XNA itself is a slow library and should only be used for X-Box and W7 Phones. C is not as slow.
    How can that possibly make sense?

    "It's slow so put it on a slow phone!"


    Quzah.
    Elysia likes this.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Aug 2011
    Location
    US
    Posts
    6
    Actually, I have several friends that have a W7 Phone and the phones aren't slow at all.

    Thanks
    Aaron

  10. #10
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Litarded View Post
    ...and the phones aren't slow at all.
    Slow is a relative term, what may be fast for you is not necessarily so for another.
    So, ...specify a frame of reference during such comparisons.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  11. #11
    Registered User
    Join Date
    Sep 2009
    Posts
    48
    There's really nothing wrong with using C#/XNA to program games; the slight performance disadvantages over C/C++ with DirectX/OpenGL will generally not be a problem unless you're doing some really highly performance critical stuff, and if you're just starting out you wont need to worry about that yet. You will learn the fundamental concepts involved in games programming with XNA, and it is easier to do so over DirectX with C++, so it's certainly not a bad place to start.

    If you're interested in releasing a game on Xbox, it's certainly easier to get the game on there using XNA and XBLIG, although Indie games are hit with some limitations (such as content size limitations of about 150-250MB, no achievements, and no Xbox LIVE leaderboards). Microsoft only really let experienced, renowned, and trusted development companies develop games for Xbox/XBLA using C++ libraries.

    If you want to get a job in the games industry then C++ is definitely the way to go, but you can learn the specifics of C++/DirectX/OpenGL after learning the fundamentals of game programming with XNA. While some low level programmers will use Assembly or C for some performance improvements, the vast majority of work is done in C++. C++ is also the primary language supported by the PS3, which you may end up developing for if you become a professional developer.

  12. #12
    Registered User
    Join Date
    Aug 2011
    Location
    US
    Posts
    6
    Quote Originally Posted by Ushakal View Post
    -Snip-
    OK, Thanks for the input.

    I have in fact made a game in C# using XNA and it was nothing I liked. So that's why I started learning C/C++. But I will take into considerate, C++ for games.

    Thanks,
    Aaron

  13. #13
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    I would not learn C at all and look at C++.

    Trouble is that C# with the XNA framework does MOST of the background work for you, while C++ does nothing.

    C++ has no garbage collection, no framework running a game timer, loading resources, drawing or init events etc.

    Expect to spend a considerable amount of time (probably years) learning C++ before you can to code any game complex enough to notice the difference in speed between C++ and C# / XNA.
    msh likes this.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  14. #14
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,259
    If you buy any indie games in particular on Steam or equivalent digital download provider these days, you'll find that more and more are being developed with C#/XNA. The distribution sizes usually make me hurl somewhat (~500MB for a "retro platformer"?!? ) but for what they do they are quite fast on an average/modern PC.

    The only time you're likely to notice creaking is when trying to do something with considerable 3D poke, "hyper realism" blah blah blah. Manipulating more than about 10,000 objects per frame. This is simply because of the amount of checking within the runtime that goes on with each function call, if you're doing this millions of times per frame then it adds up.

    C++ has less of this, but conversely some things you have to develop a way of doing yourself. This isn't a bad thing really, as the one thing you'll learn is that a general case is a general case; you can make better for your particular application.

    C++ runtimes also allow you to customize how much "help" you want. You can turn 99% of it off if you want, but don't think that the compiler will implicitly do a bad job; Only turn things off if you notice an improvement and nothing breaks.

    C is about as simple as it gets. No help. You can do fun things like multiple inheritance but you will have to make ALL the handling yourself (and it's a lot of messy work, I've done it ).

    As others have said, C++ is probably the best bet in terms of flexibility, but it's not easy to get to grips with. Why not learn C# and move on to C++ when you're ready?
    stahta01 likes this.

  15. #15
    Banned
    Join Date
    Sep 2011
    Posts
    1
    I would go with C++. Check out SFML for graphics, sound, network and input. The combination of them both is really easy to learn, and once you learn it, it's really powerfull.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DOS Games
    By ThLstN in forum Game Programming
    Replies: 26
    Last Post: 06-20-2008, 04:34 PM
  2. Games + C++
    By Nestor in forum C++ Programming
    Replies: 4
    Last Post: 06-19-2008, 12:53 PM
  3. c++ games comparable to psx games?
    By anarchyhollow in forum Game Programming
    Replies: 17
    Last Post: 01-08-2003, 07:49 PM
  4. Just Games IDE
    By JoshG in forum Game Programming
    Replies: 2
    Last Post: 06-24-2002, 02:58 PM
  5. C++ Games
    By NewbieVB in forum Game Programming
    Replies: 5
    Last Post: 04-14-2002, 09:33 AM

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