Jump to content

  • Log In with Google      Sign In   
  • Create Account


How many of you use C for game programming?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
108 replies to this topic

Poll: How many of you use C for game programming? (152 member(s) have cast votes)

Do you use C?

  1. Yes (30 votes [19.74%])

    Percentage of vote: 19.74%

  2. No (80 votes [52.63%])

    Percentage of vote: 52.63%

  3. Sometimes (42 votes [27.63%])

    Percentage of vote: 27.63%

Vote

#41 typedef struct   Members   -  Reputation: 230

Posted 25 January 2011 - 04:09 PM


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?


Is this a serious question? I'm saying that the advantage of C over assembler is huge compared to the disadvantage. The advantage of C++ over C is considerably less compared to the disadvantage. Using C over ASM is a no-brainer. Using C++ over C is less of an obvious decision.
Anthony Umfer

Sponsor:

#42 stupid_programmer   Members   -  Reputation: 898

Posted 25 January 2011 - 04:31 PM

As a general statement that is just plain not true. In some industries, sure, but as a blanket statement, no way. I spent two years working in a Java shop, on large server software, and event here an integral task had to be delegated to C++[1] (nevermind maintenance tasks which were generally scripted in bash). Outside of the enterprise-bloatware world, there are still a lot of people using C++. In game development, C++ is still very much winning over Java.


There are also far, far more people doing enterprise development then games (even then a large subset of games are Java based). And Java is the dominate language in enterprise development. C++ use has actually been going down and I would image it won't be to long before C# even overtakes C++ (if it hasn't already). I would imagine the only reason C++ still has any kind of serious widespread use is from library inertia. Dealing with C++ hell instead of spending the next two years rewriting the project is probably the only viable option for a lot of businesses.

#43 kalmiya   Members   -  Reputation: 468

Posted 25 January 2011 - 04:56 PM

In my experience, in C++ project people tend to write more "fluff". Especially beginners tend to make a mess of classes and create complex dependencies.
Especially things like "Let's encapsulate it (because I don't want to use the other persons class directly)" leads to lots of bloat and unneeded interfaces.
The same with making it futureproof (for any eventuality) - rather then just hardcode the limited # cases actually needed (and get it done) - we are adding
more "fluff which might (but probably won't due to changing requirements) be used in the future,

In some projects I saw multiple classes, interfaces, factories and stuff - which could have been hardcoded with just a few simple lines - instead everything
is delegated to another class which i turn delegates it again. Much overhead and little code actually doing something for the end-product.

So I started doing a multiplatform mini-project (osx, iphone, win32) in plain-C a few months ago - after programming for many years in C++.

I set the followig guidelines for myself:
- "If it takes much lines-of-code, rethink it because that solution is wrong ^^
- "it's done when it's impossible to remove any code (as opposed to "it's done when you couldn't possiblily add anything more - that might _potentially_ be used")
- Add on-demand (don't look too much forward) - eg: no programming an entire matrix-class with all possible functions - if you currently only really need matrix-mul).
- Don't be over-flexible/extensible (if I need 5 of something then "Something s[5]" will do fine - no factories, managers or dynamic datastructures needed).

Sure, I miss template-containers - and yeah, you darn well know what you are doing with those void*'s - but it does have it elegance and simplicity.
Anyway, don't just discard C because "it's old and C++ is better".

Just my 2 ct :)
visit my website at www.kalmiya.com

#44 trzy   Members   -  Reputation: 100

Posted 25 January 2011 - 04:59 PM

I tend to use C more but I've been transitioning to C++ slowly. I can see the appeal of OOP, particularly for data structure-intensive tasks, but I think a lot of OO design principles are overblown, namely "data hiding" and "reusability". A lot of code that I write is not going to be reused or, if it is, is going to be implemented in a radically different fashion. On the current project that I'm tinkering with, an emulator, objects seemed compelling from a design standpoint but looking back now, I realize that the core functionality of the program should be done in a procedural fashion, with a few objects here and there for things that either are truly well encapsulated or interchangeable and which would benefit from concepts like inheritance. I'm discovering that when the functionality of different modules is tightly coupled, accessor functions and data hiding really do result in over-designed solutions.

Furthermore, I haven't been very impressed with STL and have been using the old standard C library for file I/O and string handling. I need to be able to gracefully handle errors and doing it with STL and a bunch of try-catch blocks is hardly elegant or foolproof.
----Bart

#45 Madhed   Crossbones+   -  Reputation: 2014

Posted 25 January 2011 - 05:37 PM

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.


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 assembler over some struct/functions 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 assembler, but just requires a bit more effort.

I wrote my first 3rd person shooter game in assem.... oh no, I didn't :lol:

C++ offers the programmer some more tools than C. Either you make use of them or you don't. Or you ABuse them. I guess C++ actually makes you think of what you are going to program, because if you don't, you'll end up with a big pile of junk.

#46 C-Lesh   Members   -  Reputation: 124

Posted 26 January 2011 - 12:43 PM

Amazing how big this thread got. Anyways, here are some stats from a projects I did in the past, a level editor:

C: 400 lines of code
C++: 1200 lines of code

Nerd's Quote: "If you stare at a computer for 5 minutes you might be a nerdneck!"
C-Dev: http://www.francoiscdev.com - Home of the game development language C-Lesh and the Super Mario World game engine!


#47 kalmiya   Members   -  Reputation: 468

Posted 26 January 2011 - 03:09 PM

I guess C++ actually makes you think of what you are going to program, because if you don't, you'll end up with a big pile of junk.


lol, exactly my point - I witnessed a substantial amount of programmers ignoring the "think" step, ending up with a big pile of junk ^^
visit my website at www.kalmiya.com

#48 BeerNutts   Crossbones+   -  Reputation: 2191

Posted 26 January 2011 - 04:23 PM

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 assembler over some struct/functions 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 assembler, but just requires a bit more effort.

I wrote my first 3rd person shooter game in assem.... oh no, I didn't :lol:

C++ offers the programmer some more tools than C. Either you make use of them or you don't. Or you ABuse them. I guess C++ actually makes you think of what you are going to program, because if you don't, you'll end up with a big pile of junk.

(Madhead, your post is a complete waste of time, and in no way represents practical thinking from anyone. here's another)


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

I wrote my first 3rd person shooter game in machine c.... oh no, I didn't :lol:



My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#49 Madhed   Crossbones+   -  Reputation: 2014

Posted 26 January 2011 - 05:25 PM

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

I wrote my first 3rd person shooter game in machine c.... oh no, I didn't :lol:


No, no, no... let's try another one.

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

I assembled my first 3rd person shooter game with transistors.... oh no, I didn't :lol:


#50 Madhed   Crossbones+   -  Reputation: 2014

Posted 26 January 2011 - 05:29 PM

Amazing how big this thread got. Anyways, here are some stats from a projects I did in the past, a level editor:

C: 400 lines of code
C++: 1200 lines of code


C++ being a superset of C (yeah... I know. Let's just pretend), 800 lines of your C++ program were superfluous, or you implemented additional features. :P
Even if you didn't mean to implement new features you probably did: Type safety, buffer overflow protection, ...
Let me get this straight, I'm in no way a C++ fanboy but the neverending C++ bashing gets a little on my nerves. There is no such thing as a perfect language, only different tools for different jobs.

#51 C-Lesh   Members   -  Reputation: 124

Posted 27 January 2011 - 05:32 PM


Amazing how big this thread got. Anyways, here are some stats from a projects I did in the past, a level editor:

C: 400 lines of code
C++: 1200 lines of code


C++ being a superset of C (yeah... I know. Let's just pretend), 800 lines of your C++ program were superfluous, or you implemented additional features. :P
Even if you didn't mean to implement new features you probably did: Type safety, buffer overflow protection, ...
Let me get this straight, I'm in no way a C++ fanboy but the neverending C++ bashing gets a little on my nerves. There is no such thing as a perfect language, only different tools for different jobs.


Someone's mad! Anyways, most of this extra code seems to be accessor functions and such. Not necessarily extra features.

Nerd's Quote: "If you stare at a computer for 5 minutes you might be a nerdneck!"
C-Dev: http://www.francoiscdev.com - Home of the game development language C-Lesh and the Super Mario World game engine!


#52 Tachikoma   Members   -  Reputation: 548

Posted 27 January 2011 - 06:59 PM

Personally I do prefer C++ over C, even though the current project I'm working on is in C. Mostly because of C++ constructor and destructor mechanisms, but small things like passing by const reference, namespaces, encapsulation and exception features are a real treat. Also, perhaps I'm one of the few people on this world who likes C++ using templates. I use OOP, but I don't go overboard with it. I think OOP can become quite convoluted and detrimental at some level, especially when your inheritance graph becomes large. So I just stick with just a handful of design patterns that work well and don't complicate things too much.
Latest project: Sideways Racing on the iPad

#53 Bregma   Crossbones+   -  Reputation: 4358

Posted 28 January 2011 - 08:40 AM

I'm currently writing a bunch of software in C, chosen for political reasons. It is taking me weeks to write something that would take a couple of days for me to do in C++. Much of the time is taken up reimplementing stuff that is handy and available in the C++ standard library, which necessitates writing the accompanying unit tests and fixing plenty of bugs due to the lack of type safety and compile-time checks, and also due to reasoning on how to properly perform error handling and unwinding. This is professional low-level production-quality code, so I can't just do the usual C trick of ignoring errors and resource allocations. Keep in mind I have 30 years professional experience writing C code and only 20 years professional experience writing C++ code (and the latter language has changed a lot over 20 years).

I would never choose to write a game in the C language: it would never get finished. I would still be stuck reimplementing all the dynamic containers and tree traversal algorithms that come for free with C++ and boost.

Oh, and the frequent argument here that people write bad code in C++: heh, people write bad stuff in any language. That's not an argument against using the language, it's an argument against paying the writer.
Stephen M. Webb
Professional Free Software Developer

#54 Mike.Popoloski   Crossbones+   -  Reputation: 2807

Posted 28 January 2011 - 12:37 PM

People only prefer C over C++ when they don't know how to write idiomatic C++ code. C++ provides constructs that address the most glaring and painful flaws in C, such as shared pointers and containers over manual memory management, standard types such as std::string over raw char arrays, type-safe variants of C preprocessor features, and constructors/destructors/RAII over manually calling Init()/Release() pairs, which is prone to breaking invariants.

The best way to write code is to design it so that there is no *possibility* of errors, rather than trying to ensure that you've accounted for all the things that might cause one. Rather than writing documentation, doing code reviews, and memorizing the fact that you *must* call Init() and Release() on your data, it's far easier and safer to utilize language constructs to ensure that there's no possible way to *not* call them. C++ provides features to make such programming easier than C. Of course other languages take it further than that, which is why I don't think C++ is all that great a language, but trying to argue that C is somehow better in any situation other than a few niche domains is simply foolish ignorance or willful stupidity.
Mike Popoloski | Journal | SlimDX

#55 geolycosa   Members   -  Reputation: 217

Posted 28 January 2011 - 12:58 PM

Linus Torvalds (somewhat angrily) on the subject: link

EDIT: Also here.
Will Miller | Game Designer | Big Huge Games

#56 szecs   Members   -  Reputation: 1986

Posted 28 January 2011 - 02:07 PM

Linus Torvalds (somewhat angrily) on the subject: link

EDIT: Also here.


Um, I'm not an expert and lazy to copy that into google, but isn't that the Finnish idiot Linux guy?

#57 MrDaaark   Members   -  Reputation: 3535

Posted 28 January 2011 - 03:15 PM

Linus Torvalds (somewhat angrily) on the subject: link

EDIT: Also here.

There's nothing of value in those posts. It's a religious tirade by Linus and nothing more. he's stuck in his old mindset, and he's doing a different type of work than most programmers, who are writing user software, and not kernels, or anything at the system level. Also, the type of stuff Linus and other C++ detractors use as arguments against the language are really just arguments against bad programmers.

To the OP: There is nothing wrong with using C for your games. C is still a perfectly fine choice of a programming language, just like all others. But it may start to hold you back a bit once your skills progress, and you need to start re-implementing features that every other language will give you for free out of the box.

Also, implementing that stuff on your own will only result in something that is likely plagued with pointer and memory errors. It's a classic trap to fall into. The days when everyone was independently solving all these problems on their own were the days of horribly insecure and unstable software.

Almost everything in the old C standard library has been declared as insecure, and has been replaced with safer alternatives. Like strtok() is now replaced with strtok_s(). Most times when people say that they can handle these things on their own easily, they write software that is 95% likely to halt with a protection fault of other similar type of error.

Modern C++ (and other modern languages) give you all kinds of options to handle these problems so you don't have to. Then you can focus on getting your actual software done, and not have to spend time solving these problems that you shouldn't have had to even think about in the first place.

#58 mikeman   Members   -  Reputation: 2050

Posted 28 January 2011 - 03:32 PM

I talk for myself...Personally, I don't have much reasons to use C. I use C++ for my current project, for all the "goodies" that come with it, but have taken the decision to not bloat it with unnecessary meta-programming stuff that are hell to read(for me anyway). I use it for the SC++L, some of boost, RAAI and that sort. And I will probably use C# for some editor/GUI things. I just don't have any reason for C, atm.

#59 sindisil   Members   -  Reputation: 347

Posted 28 January 2011 - 11:08 PM

People only prefer C over C++ when they don't know how to write idiomatic C++ code.


That's simply not true. There are plenty of us who both know C++ well, and still prefer C. In my case, in fact, I think it's *because* I know C++ well that I prefer C.

I've been coding in C since the early 80s, and C++ since around 1989 or 1990. I develop professionally using both (as well as other languages), and I can and do use C++ in an "idiomatic" way, including RAII, use of the stdlib, etc.

I still very much prefer C over C++. In fact, it's not even close.

Sure, there are things that I like about C++ in theory, but in practice, C++ is such a muddled and overcomplicated mess that I'd rather just avoid it.

but trying to argue that C is somehow better in any situation other than a few niche domains is simply foolish ignorance or willful stupidity.


With all due respect, that's a rather simplistic and close minded attitude. They're tools, and, as such, suite individuals better or worse in turn.

#60 magic_man   Members   -  Reputation: 54

Posted 31 January 2011 - 08:56 AM

People only prefer C over C++ when they don't know how to write idiomatic C++ code.


That

is simply foolish ignorance or willful stupidity.





"You insulted me!" I did not say that in the private message Tom Sloper!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS