• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Links to articles/data on C vs C++

## Recommended Posts

Can anyone provide me with some links to articles/raw data/info on C vs C++. ie speed, code, benefits, etc. I already read the info in the "What Language" artticle in the articles section of this site. Posting this here as it seems to be in the "Game Design" area - if not, my aplogies - and feel free to direct me to where you think it should have been posted :-) Thanks, Edited by - a_question on January 11, 2002 6:45:31 PM

#### Share this post

##### Share on other sites
No offence, but does it really make a difference anymore? If I had to chose I''d pick Win32ASM.

If you want to make fast optimized code, then learn your language REALLY well, that''s where the speed difference happens.

Sorry if this didn''t answer your Q, I just find it a bit silly.

#### Share this post

##### Share on other sites
> No offence, but does it really make a difference anymore

No offence, but if you were a team leader with experience developing several C based projects, and a proposal was made to you saying "Lets switch to C++ for our next project", and when you asked why you got the response "Does it really make a difference", how much stock would you put in that proposal?

> If I had to chose I''d pick Win32ASM

Id hazard a guess that this would be rather difficult to implement on playstation/gamecube/etc platforms.

Anyway, I''m just looking for a comparison/benefits/insight anyone has on using functional vs object oriented design methodologies as they pertain to game development.

#### Share this post

##### Share on other sites
I''ll try answering the second part of your original post...

...try the Game Programming forum, they''ll jump all over your question.

#### Share this post

##### Share on other sites
Sure - I see it as a game design question, but not within the context of what this fourm is used for. Ill take your advice and move it to the game programming fourm; it makes more sense there.
And sorry if my last post came off as a partial flame - it wasent meant ot be, but re-reading it im sure it could be conscrued that way :-) I just dont think its a silly question, thats all :-)

#### Share this post

##### Share on other sites
The only "silly/dumb" questions are those that have already been answered.

"If you do not ask, you shall not receive."

-Rick

#### Share this post

##### Share on other sites
quote:
Original post by a_question
Can anyone provide me with some links to articles/raw data/info on C vs C++. ie speed, code, benefits, etc.

I know you''ve already been directed to another forum, but I''ll jump in and give you an excellent reference on why there is no reason NOT to use C++ in your projects:

Efficient C++ - Performance Programming Techniques. Dov Bulka & David Mayhew, Addison Wesley, ISBN 0-201-37950-3.

That''s an unbiased, straightforward explanation of many of the performance caveats of C++ and Object Oriented Programming in C++, along with excellent explanations of how to avoid them to make your code equally fast as something written in pure C, but more readable.

People might not remember what you said, or what you did, but they will always remember how you made them feel.

#### Share this post

##### Share on other sites
*votes for object oriented*

Zaphire Productions

#### Share this post

##### Share on other sites
Somehow I just can''t imagine programming in C... argh, no structure, no beauty. ;-)
If doing a game project C++ ist must. Any programmer who has not yet learned C++ has not done his job proberly.

------------------------------
www.BadEntertainment.net

#### Share this post

##### Share on other sites
I agree that performance isn''t an issue with C++, if you know what you''re doing at least. And, if you reach the point where the performance gained by the language counts, you prolly know what you''re doing.

But I like C more than C++ because it''s cleaner, more honest and plain powerfull without losing simplicity.

I like the C header files way more than the ugly C++ header files. If in a C++ header you add tons of private stuff noone needs to know about, in C you just add a function or three.

I like C because there aren''t so many namespaces. Not confusing at all. Everything global and that''s it. An advantage is that making minor architecture changes is trivial. Try splitting a C++ class that you derive another class from that you derive another class from in two separate structures.

I like the C naming conventions. In C you always know at all times what functions and variables come from what module. Browsing through code is a lot easier. I don''t have to keep track of the class a function belongs too. I also find having different functions names for different param types helpful. All the info I need I can get from reading the code.

#### Share this post

##### Share on other sites
Looks like this would get a better response in Game Programming.

--------------------
Just waiting for the mothership...

#### Share this post

##### Share on other sites
Anyone who has a true grasp on object oriented programing will never want to go back. But then again anyone who has a tryed and proven methodology in C may never want to spring for C++. The truth is that C++ is far superior to C in terms of intuitiveness. And if your a beginning programer thats exactly what you want. Unfortunatly C++ was built on C and thus suffers from a bad "identity crisis" in which there are way too many ways to do anything (which is probably a good thing). Personally I could not deal with programming in C now that I have experianced C++. Also you can program C style in C++ so their is no excuse for using C.

SniperBoB

#### Share this post

##### Share on other sites
quote:
Original post by Diodor
I like the C header files way more than the ugly C++ header files. If in a C++ header you add tons of private stuff noone needs to know about, in C you just add a function or three.

What, no variables?

That points to one of the perceived "deficiencies" of C - the fact that the data you operate on is dispersed throughout the application and vulnerable to modification from a thousand places (which also makes it harder to trace some bugs).

quote:
I like C because there aren''t so many namespaces. Not confusing at all. Everything global and that''s it.

Not anymore, my friend. See C99.

quote:
An advantage is that making minor architecture changes is trivial. Try splitting a C++ class that you derive another class from that you derive another class from in two separate structures.

If you need to do that in C++, your design was probably bad in the first place and you should be punished for it. However, it''s very possible:
class A; // original base classclass B : public A; // original derived class.// refactored design:class A1;  // new split implementationclass A2;class A : public virtual A1, public virtual A2;class B : public A;

Remember, we have multiple inheritance too.

quote:
I like the C naming conventions. In C you always know at all times what functions and variables come from what module. Browsing through code is a lot easier. I don''t have to keep track of the class a function belongs too. I also find having different functions names for different param types helpful. All the info I need I can get from reading the code.

I don''t get this. You''re saying we can''t get where a function comes from in C++? Let''s see:
// C:void Draw(Sprite *pSprite);void Draw(Obj3d *pObject);...// C++void Sprite::Draw();void Obj3d::Draw();

Not only is the C++ clearer in establishing relationships, it also is easier to use in loops in conjunction with either inheritance (make the function virtual) or RTTI (which C plain doesn''t have). Unless, of course, I totally misunderstood your point (in which case I apologize).

Don''t get me wrong, I love C as much as the next guy. But don''t put C++ down on invalid arguments. Choosing between C and C++ is a preference and a function of impression (what you''re told when you''re starting out). I was told straight up to ditch C and go for C++ (this barely 3 months after starting out), so I hold that view since it worked for me.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

#### Share this post

##### Share on other sites
You sound to me like you are a beginner to programming. If this is so then you should learn to program in the basics of c then c++. Check out etheir this site or
www.geocities.com/gcgameruk

#### Share this post

##### Share on other sites
Thanks all for your input - this is exactly the type of thing im looking for! :-)

Ive ordered the book as well, MadKeithV. Thanks!

> Anyone who has a true grasp on object oriented programing will never want to go back. But then again anyone who has a tryed and proven methodology in C may never want to spring for C++

This pretty much hits it on the head. Im familiar with C, but am curious about C++. So, im learning C++ - (language is NP, how to think/design in a OOD manner is a bit tougher :-) ), and asking around in various forms to see if people have any info. Book reccomendations are welcomed as well! :-)

#### Share this post

##### Share on other sites
every language has it''s purpose. furthermore i would rather be schooled in the fundamentals and theories of programming than grasp to a particular language as if it were my last kidney. if you understand HOW TO program then you will be able to apply your knowledge effectively to whatever language you choose. IMO, c would be appropriate for tight, low-level (i.e. low-level driver, i''m talking kernel level). where c++ is more of an application level language. this is just an opinion, and i''m sure you could argue either way. i personally wrap a lot of ANSI c functions with c++ classes for portability (i.e. my own "File" class that wraps "fopen, fclose, etc").

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

#### Share this post

##### Share on other sites
You''re all fools!
The Great Computer Language Shootout

We should all be programming in Ocaml, at least according to these weights.

#### Share this post

##### Share on other sites
I highly suggest you go here and download this book, Thinking in C++

http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html

He compares the 2 very well at the same time teach c++. Excellent reference.

#### Share this post

##### Share on other sites
quote:
Original post by Stoffel
You''re all fools!
The Great Computer Language Shootout
I love it!

We should all be programming in Ocaml, at least according to these weights.

But since we aren''t, we at least choose the next best thing (C++)! And ocamlb doesn''t count since it doesn''t compile to native code!

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

#### Share this post

##### Share on other sites
" I know you''ve already been directed to another forum, but I''ll jump in and give you an excellent reference on why there is no reason NOT to use C++ in your projects:

Efficient C++ - Performance Programming Techniques. Dov Bulka & David Mayhew, Addison Wesley, ISBN 0-201-37950-3. "

The book came in today, and is _exactly_ what I was looking for.

Thank you very much!

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627654
• Total Posts
2978451

• 10
• 12
• 22
• 13
• 33