Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

How much faster is C compared to C++?

This topic is 5037 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Exactly the same.

Most of today's C compiler really are C++ compilers. The parser may different, but the code generating engine remains the same.

If you were to implement, by hand, C++-equivalent constructs in C (e.g. polymorphism...) you would probably end up with a slower and kludgier solution.

Share this post


Link to post
Share on other sites
All things being equal, they should compile into pretty much the same instructions, hence the same speed.

Realistically, you should use whatever you create more maintainable, bug-free, and elegant code, as missing those will influence the speed of your program by orders of magnitude more than the speed difference between C and C++

Share this post


Link to post
Share on other sites
Just one more quick question, so C doesnt have classes but has structures?

And anyone know where I can find some OpenGl tutorials written in C?

Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by johnnyBravo
Just one more quick question, so C doesnt have classes but has structures?


C has struct and union, as well as enum.

Quote:
And anyone know where I can find some OpenGl tutorials written in C?


Nehe Tutorials on Gamedev.net
OpenGL.Org/
and in the Red Book (online)

Share this post


Link to post
Share on other sites
Quote:
Original post by johnnyBravo
Hi, I was wondering if anyone knew averagely, how much faster C is, compared to C++.


C is slower than C++

Share this post


Link to post
Share on other sites
Quote:
Original post by petewood
Quote:
Original post by johnnyBravo
Hi, I was wondering if anyone knew averagely, how much faster C is, compared to C++.


C is slower than C++

and C is still slower than assembly!
if you want a realworld/game context example checkout the quake .net port:
How is the performance of the managed version?
Initially, the managed version was faster than the native version when the default processor optimization setting /G5 (Pentium) was used. Changing the optimization setting to /G7 (Pentium 4 and Above) created a native version that runs around 15% faster then the managed version.


Note, the assembly code was disabled for the native and managed versions so both versions are slower than the original Quake version

Share this post


Link to post
Share on other sites
Quote:
Original post by petewood
Quote:
Original post by johnnyBravo
Hi, I was wondering if anyone knew averagely, how much faster C is, compared to C++.


C is slower than C++

Share this post


Link to post
Share on other sites
Quote:
Original post by petewood
Quote:
Original post by johnnyBravo
Hi, I was wondering if anyone knew averagely, how much faster C is, compared to C++.


C is slower than C++


Really what do you base that on? I'd really like to know just pulled it out of your arse or?

Anyway from my experience with gcc/g++ c++ seems to have a slightly higher memory usage than c, and is also slightly slower when you fully utilize such features as polymorphism etc. When using linux you could use the icc compiler tho since it briungs the c++ up to pretty much the same speed as c code. It really depends on what compiler you use, g++ has had some issues and hopefully they will be/are solved ;) Until then I'm gonna stick to C(gcc) for time critical low level stuff. I doubt you are using linux tho so just go with whatever feels right.

Note: all of the above is MHO so don't get too excited.

- Damage Incorporated.

Share this post


Link to post
Share on other sites
c speed==c++ speed

The only way c++ would be slower is if you use things like polymorphism. And that is not due to the language but the design. If you design your program right however using polymorphism (etc.) the speed diffrence is very very marginal.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!