Question about c,c++,direct x and game development

Started by
18 comments, last by _the_phantom_ 14 years, 3 months ago
Quote:Original post by phantom
If anything, this mixing of C and C++ is probably partly to blame for so much bad C++ existing because people treat C++ as 'C with classes' and end up writing bad code and missing out on the many features of C++ which would allow them to write better programs; both in code quality and execution speed.


Do you have any data to back this up or is this just your opinion?

To say "better programs" implies that C++ is an inherently better language than C which is ridiculous. It's ultimately about the coder's level of knowledge, not the language. I've seen very ugly "pure C++" code.
Advertisement
Quote:Original post by phantom
Its not semantics because they are two different languages (which is why I cringe when someone says C/C++) and really should be treated as such.


Very well then...phantom advocates not using the "for" statement because it was a C statement.
Quote:Original post by lakmir0
Do you have any data to back this up or is this just your opinion?
If it's "only" opinion, I'd say it's at least a fairly common opinion.
Quote:Original post by lakmir0
To say "better programs" implies that C++ is an inherently better language than C which is ridiculous.
That's not quite true. The comparison is more like a native speaker of English vs. someone who speaks English with a heavy accent. It's not that English is "inherently" better than any other language or that a native English speaker is inherently better at communication, but a native English speaker will be able to communicate better in English than someone who speaks English with a heavy accent.
Quote:Original post by lakmir0
Very well then...phantom advocates not using the "for" statement because it was a C statement.
Yeah, and you shouldn't use "if" since that's COBOL... yuck!
Quote:Original post by Codeka
Quote:Original post by lakmir0
Do you have any data to back this up or is this just your opinion?
If it's "only" opinion, I'd say it's at least a fairly common opinion.
Quote:Original post by lakmir0
To say "better programs" implies that C++ is an inherently better language than C which is ridiculous.
That's not quite true. The comparison is more like a native speaker of English vs. someone who speaks English with a heavy accent. It's not that English is "inherently" better than any other language or that a native English speaker is inherently better at communication, but a native English speaker will be able to communicate better in English than someone who speaks English with a heavy accent.
Quote:Original post by lakmir0
Very well then...phantom advocates not using the "for" statement because it was a C statement.
Yeah, and you shouldn't use "if" since that's COBOL... yuck!


You must be one of those C++ fanboys. Yeah, no point talking any further then.
Quote:Original post by lakmir0
You must be one of those C++ fanboys. Yeah, no point talking any further then.
I thought my response was quite reasoned... but, whatever.
Quote:Original post by Codeka
Quote:Original post by lakmir0
You must be one of those C++ fanboys. Yeah, no point talking any further then.
I thought my response was quite reasoned... but, whatever.


It's not reasoned to say C++ is easier to "communicate" with...it's blooming absurd. C is a very flexible language and it integrates well with many other languages as well.

C++ is good for what it does. I like a certain amount of OOP but I also know how to code without.having.to.make.everything.class.oriented.

I once heard a joke about OOP that is true in a lot of circles..."OOP is like sex...everyone talks about doing it but few are actually doing it."

Don't bother arguing over this...we both obviously have our opinions fixed.
Quote:Original post by lakmir0
It's not reasoned to say C++ is easier to "communicate" with...
Right, but that's not what I said. I said it's easier to "communicate" if you use C++ correctly (as opposed to using C++ incorrectly, not as opposed to communicating in C or some other language).
Quote:Original post by lakmir0
I once heard a joke about OOP that is true in a lot of circles..."OOP is like sex...everyone talks about doing it but few are actually doing it."
I actually think we agree. The discussion is not about which language is "better", but whether you're using the language you've chosen the way it's supposed to be used. If you're using C++ as "C with classes" then you're not using C++ the way it's supposed to be used.
Quote:Original post by lakmir0
To say "better programs" implies that C++ is an inherently better language than C which is ridiculous. It's ultimately about the coder's level of knowledge, not the language. I've seen very ugly "pure C++" code.


No, I was talking purely in the context of writing C++ code.

And yes, it is ultimately about the user's level of knowledge, however with C++ often that level of knowledge reaches a point where they can use it and they don't bother looking any further, at which point many people hit the 'C with classes level'.

Take for example the for loop; there is nothing wrong with the for loop as it is clearly part of the language. However, there is a very good chance that using something like std::foreach when going over a container (or memory block) will be faster because the compiler can (and most certainly does) fold more code together thus producing better performing code.

Now, you might say 'this is ugly' but I would argue that the reason it seems ugly is simply because you aren't used to it because so many people DONT write C++ "properly".

If anything I find C++ written like this to be better to read because I can make assumptions quickly about the code and things like the loop body is isolated away from the loop meaning that, with a well named class/functor, on initial look at the code I don't have to worry about what the code is doing.

Maybe in the cold realities of the commerical world good C++ practise goes by the way side, but that is no reason NOT to learn it in the first place. If you know it then you can, at the very start of the project at least, enforce it and use it which then gives you a solid start for the rest of the project. If you don't know it then you'll never use it and you'll never know what you are missing out on.

It also saves you coming across situations I did where I was working with someone who had been in the games industry for 5 years and had NEVER written a virtual function. His method of doing thing was to copy and paste code about when he needed the same functionality in related classes. This lead to code bloat, harder to maintain code and bugs which got fixed in one place and not in another. When we were working on a menu screen system for a game at work I could see a natural solution involving a small inheritance chain and a couple of virtuals; it was my area of code but I was going on holiday for a couple of days, so I outlined it to two guys (one being new to the company, the other the no-virtual guy) using standard C++ phrasing, asked if they were ok with it, which they apprently were, and went off for a long weekend.

I returned to find my design hadn't been implimented, instead a clugged involving C-style callbacks, copy and pasted code and far far more lines than required had been done and worked into the game which lead to me spending the next couple of days detangling the mess and fixing it up so that it was better and leaner code which did more.

So, yes, knowing how to use your language of choice is important and should be done properly.
Quote:Original post by phantom
I returned to find my design hadn't been implimented, instead a clugged involving C-style callbacks, copy and pasted code and far far more lines than required had been done and worked into the game which lead to me spending the next couple of days detangling the mess and fixing it up so that it was better and leaner code which did more.


I really don't think C was a problem here, more so the person who implemented it. C may not have all the nice object oriented features that C++ has but it's far from being hard to manage. Instead of writing spaghetti code he could have thrown the repeated code into a function. Even if your co-worker knew the C++ standard to the T, he'd probably still screw it up.
I never said C was the problem, I never even mentioned C in the post. I have nothing against C and I'm at a loss to explain why people are getting the idea that I do. Hell, I doubt his solution was even good C either.

I specifically was talking about how his lack of knowledge about the language was a problem. If he understood C++, even slightly better, then sure he might not have come up with the best design but it would have been better C++ (and would have cost me little to no time to refactor it later if needs be).

This topic is closed to new replies.

Advertisement