How many of you use C for game programming?,
Members - Reputation: 136
Posted 23 January 2011 - 10:33 PM
Nerd's Quote: "If you stare at a computer for 5 minutes you might be a nerdneck!"
"I got an $86000 company, what do you have a**hole?"
"After 10+ years FrancoisSoft is back? Yep, and we're here to stay. It'll be a good time!"
"The Super Mario World Tournament is here! Will I win or will I lose it all?"
FrancoisSoft on the Web: http://www.francoissoft.net:3000 <- Inquire for account.
Moderators - Reputation: 48908
Posted 23 January 2011 - 11:15 PM
If that's your problem with C++ (or OOP?), then you're using C++ wrong.
I use it myself because of its simplicity and less haggling with accessor functions, member access, etc.
I voted sometimes -- I mostly only use C for gluing different systems/modules/languages together.
Crossbones+ - Reputation: 5069
Posted 23 January 2011 - 11:54 PM
Seriously, after working with std::string and the other STL containers it's hair raising annoying having to resort to C instead of C++. I sometimes have to at my work place and I'm glad if I can keep the C parts short.
Moderators - Reputation: 20992
Posted 24 January 2011 - 12:44 AM
Which is not to say I have any love whatsoever for C++.
Members - Reputation: 2760
Crossbones+ - Reputation: 2263
Posted 24 January 2011 - 02:55 AM
Crossbones+ - Reputation: 11709
Posted 24 January 2011 - 03:54 AM
Crossbones+ - Reputation: 1370
Posted 24 January 2011 - 04:32 AM
Members - Reputation: 271
Posted 24 January 2011 - 06:16 AM
I'm very curious. I use it myself because of its simplicity and less haggling with accessor functions, member access, etc. Though many may not agree with me. I'm just curious about what people's take on this is.
I have this crazy idea sometimes that I want to program in C so at one point I rewrote my latest project to C. I may go back at some point but I am thinking that if I need a high level language I would embed Lua instead of using C++.
I was thinking about what you say about accessor functions. You don't have to use them in C++ and you can, and sometimes should, have them when programming C. But it was quite a relief to get away from idiomatic C++ and just solve the problem. But this limitation is just our heads.
I also think C is quite fun. It is nice to find different solutions to the problems. But having to write container classes is a mess. It takes a few iterations to get them right. I know I am talking against my last paragraph where say "just solve the problem" because I would get some stuff done faster if I would stick to C++ and code with an open mind.
Also C code compiles a lot faster than C++. I think 2 or 3 times faster!
Members - Reputation: 217
Posted 24 January 2011 - 09:28 AM
Members - Reputation: 217
Posted 24 January 2011 - 12:14 PM
Yes. For an iOS game.
iOS uses Objective-C
To be clear, the iOS APIs are written in Objective-C, but your game code doesn't have to be. You can mix C and C++ with Objective-C very easily.
Members - Reputation: 860
Posted 24 January 2011 - 01:25 PM
Other than that, it's a much nicer language than C++ to use. It's simpler and doesn't have nearly as many caveats, which allows you to better focus on the problem at hand. C tends towards minimalism: "what's the simplest way to make this work?" C++ entices you to think big: "how can I make this more general reusable"? (This is a trap, don't do it!)
That said, given a choice I avoid low-level languages completely. You don't need to use C++ to create a game and you don't need C to create a reusable component. Once you manage to accept that (it's harder than it sounds) a bright new world of possibilities opens up! Life is too short to spend it working on yet another container (or waiting for it to compile).
[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]
Members - Reputation: 2760
Posted 24 January 2011 - 01:32 PM
Members - Reputation: 745
Posted 24 January 2011 - 02:15 PM
Oh and one of my big gripes is malloc and free are annoying as hell to use with all their casting clutter.
If you need to cast, then you're trying to compile a C program as C++. My favorite idiom is:
Type *var = malloc(sizeof *var); free(var);This is less brittle, more readable, and the compiler will tell you if there's no prototype for malloc(). I don't know how relevant that last part is anymore. Maybe it could cause a problem if sizeof(int) isn't the same as sizeof(void*)?
But, I still agree that there's not much use for C in game programming. The only place I could see using it would be as a lighter choice than C++ to drop down to from a higher level language, whether for speed or gluing bits together. In those cases, I see myself using mostly the C subset of C++, and C++ isn't as good at being C as C is.
Crossbones+ - Reputation: 2155
Posted 24 January 2011 - 02:24 PM
I wrote my first 3rd person shooter game in C. Saw no advantage in using C++ whatsoever, and it was easier to follow/maintain.
"Yo mama so fat, she can't be frustum culled." - yoshi_lol
"One objection to a “critique of C#” would be that you can’t talk about C# without talking about the whole “.Net experience”. However, one can approach the topic of Hitler without a complete discussion of Nationalist Socialism, so I feel justified." - Steve White.