Advertisement

How many of you use C for game programming?

Started by January 24, 2011 04:33 AM
107 comments, last by Washu 13 years, 7 months ago
I use C for almost all of my programming because I like the simplicity of C over C++. I also agree with previous posters that some C++isms make the code harder to read/follow but that's probably because I don't code in C++ much. I have yet to come across a problem that just cannot be coded in C, and any extra bit you may need to get something working in C that is "easier" in C++ seems to me is gained back in the clarity of the language.

I might get flamed for this, but oh well, I'm used to it. I think C++ promotes alot of bad programming practice and laziness, especially for beginner programmers. I don't hate C++, but I prefer straight forward C over some class/template crazy C++ code. TBH, I don't even see what makes most of those features even useful to begin with. Almost everything you can do in C++, you can do in C, but just requires a bit more effort.

I wrote my first 3rd person shooter game in C. Saw no advantage in using C++ whatsoever, and it was easier to follow/maintain.


Anything you can do in C, you can do in assembler with a bit more effort. Always use the highest level/most productive tool you can*. Time wasted doing stuff in C that "requires a bit more effort" is time that could better be spent adding features, polishing the design, etc.


*i.e. the one that satisfies your requirements for portability, performance, etc.
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
Advertisement

Almost everything you can do in C++, you can do in C, but just requires a bit more effort.


True, but then pretty much everything that you can do in C can be done in C++. All the features of C++ that C lacks are optional and if you are preferring to write procedural code, C++ can still be a better choice due to stricter type-safety.

I understand the arguments for C in terms of compilation speed, maybe easier optimisation by compilers and availability of good compilers on some platforms, but not because C++ has features that impart no overhead if you choose not to use them.
I basically use reduced C++. I don't try and use its features for the hell of it, like i've seen a number of times in the industry, i use what is useful. For example,

- I only use templates in a few core places (lists etc)
- I don't use STL anywhere.
- I don't use inheritance anywhere, i am favouring composition.
- I don't use function overloading.
- I don't use constructors for anything other than initialising members. I have Init() and Close() phases.
- I use global pointers to the main 'managers' in my project.
- I use public members if i would otherwise be writing transparent getter/setter methods.

Essentially, there are some good things about C++ and some bad things about it. You have to learn for yourself and experiment for yourself in order to learn these things. I have gone full circle, i was once a C++ purist, but i found writing pure C++ largely counter-productive. I just want to be productive and so should you.

Have fun!

Java won over C++ because of garbage collection.
I disagree. Java is a mid-level language (for lack of a better word since it's neither really high nor low level) whereas C++ is a low level language with pretend OOP. Mid-level languages with Java leading the way kicked C++ out of a lot places, but there are a few niches where C++ is still useful.

Anything you can do in C, you can do in assembler with a bit more effort. Always use the highest level/most productive tool you can*. Time wasted doing stuff in C that "requires a bit more effort" is time that could better be spent adding features, polishing the design, etc. .


This is silly. C is 10 times more productive than assembler. C++ is not 10 time more productive than C.
Anthony Umfer
Advertisement

This is silly. C is 10 times more productive than assembler. C++ is not 10 time more productive than C.

Many people would find C++ to be some bit more productive than C. I certainly do, maybe between 2x and 5x depending on what I'm doing (e.g. string manipulation). I find Ruby to be hugely more productive than C++, but I can't always use Ruby. Still others might be more productive in assembler. It depends on the individual, provided they remain aware of the "Blub paradox".

This is silly. C is 10 times more productive than assembler. C++ is not 10 time more productive than C.

So you'll only use something if it's ten times better? A car isn't ten times faster than a bike, so are you saying that we shouldn't use cars? A microwave doesn't cook food ten times faster than an oven, so are you saying that we shouldn't use microwaves?

'typedef said:

This is silly. C is 10 times more productive than assembler. C++ is not 10 time more productive than C.

Many people would find C++ to be some bit more productive than C. I certainly do, maybe between 2x and 5x depending on what I'm doing (e.g. string manipulation). I find Ruby to be hugely more productive than C++, but I can't always use Ruby. Still others might be more productive in assembler. It depends on the individual, provided they remain aware of the "Blub paradox".


One could argue that your 2x-5x increased productivity evaporates while waiting for the code to build. :P

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Since i'm a Pascal/Object Pascal man i don't use C/C++/C#.

I use VS only for compile some project of other people and dev in .Net w/ Pascal.
---------------------------------
FAR Colony http://farcolony.blogspot.com/

This topic is closed to new replies.

Advertisement