• Advertisement
Sign in to follow this  

Is making game with c possible?

This topic is 720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

TL;DR; of the abvove posts:

 

The advantage of C++ is more options to structure your code in readable ways, while not really having any disadvantages over C.

 

So the question is more "why use C?", which it seems like more and more people answer "there is no reason", so they use C++.

Edited by Olof Hedman

Share this post


Link to post
Share on other sites

or have you cake and eat it too.

 

i use a c++ compiler for the stronger compile time checking, but the code is largely C.  if i want to use C++ syntax i can.  if i don't, i don't have to.   so if i need polymorphism, inheritance, lambdas, etc, they are available. but 99% of the time, plain old C without the sugar coated wrapper of C++ syntax works just fine, and is usually less typing.

 

in general when you ask this type of question you'll get two types of responses, those from folks who only know c++ (younger programmers), and those who know there were games before C++ existed (older programmers).

 

i wrote my first PC game in 1982. so i'm definitely in the "games came before c++" group. 99% of the original purpose of c++ syntax was to make extending existing code bases easier.  unfortunately, extending exiting code bases is something that's rarely required in games.  but of course, if you've got a new hammer, you've just got to frickin' use it.  so wait!  we can also use it as a design methodoloy!  but again, unfortunately non-trivial games are about performance, not academic design methodologies / methods of source code organization.  those raised on C++ alone are usually unaware of the original purpose behind c++ syntax, and the history of the rise of OO design methodology.

 

this also speaks to the continual trend of hardware and software manufacturers coming out with new stuff (other than graphics cards), but not directly targeting games. and then feeling left out, gamedevs try to find a way to use the new tech. or non-gamedevs espouse the tech as a game solution (anyone remember MMX instructions?). in many such cases the fit between games and tech is forced or kludged or only works up to a certain point.  

Share this post


Link to post
Share on other sites

I use C quite a bit, personally. It doesn't really provide much benefit over C++. I like it because not having classes handy can push me to think about different ways to design code. I don't think I've figured out anything novel yet, though. There's only two reasons why I would recommend anyone else use C over C++:

1) You don't want to, or can't, link to the normal libraries.
2) You're considering working with a C purist.

The second reason might come up in game development. There are some C purists in the hobbyist crowd. Usually their reasons for being C purists are pretty pointless, but in my experience they're usually crazy good and worth working with just to learn a thing or two.

The first reason is not likely to come up in game development *anymore*. Even cheap low end computers have enough hard drive space and memory to make saving 1-2mb fairly pointless (this was not the case 15 years ago).

The first reason *might* come up if you're doing other sorts of programming. For example, the C runtime isn't available in an OS kernel, or on a custom OS. The C runtime might not be available in certain embedded environments. If you're writing web services using CGI (common gateway interface), cutting out some of the pre-main work might be worth it.

Like Norman, a lot of my code winds up looking like C code even when I'm programming in C++. The "C way" of doing things is usually (but not always) more efficient, but you can always do the "C way" in C++, and still get all the advantages of C++.

Edited by nfries88

Share this post


Link to post
Share on other sites

To play Devil's advocate, OOP isn't loved by everyone.

 

 

A lot of people think it is terrible.  They will say don't use C++ because it has objects.  But, as pointed out above, you can write C++ and not abuse OOP.

You need tons of games to find your style and figure out if it saves you time and energy and money, or it doesn't.

 

Don't worry about it.  Go write games.

Share this post


Link to post
Share on other sites

A great book to read, old now but what it says is still valid and will teach you a huge amount about what and why in C++ "The design and evolution of C++" by the creator of the language. It goes into the choices that were made, why they were made and give you insights into the core language that will deepen your understanding of the language. The deeper your understanding the better you can use a language and back in the day this gave me insight that no other books gave.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement