MY GOD, Does C++ suck?

Started by
12 comments, last by Sinner_Zero 23 years, 5 months ago
Ummmm.....I''ve been told that structs are faster (and thus in the end superior) to classes, is this true? Can something of C beat C++ so astonishingly? WTF is the point of classes in the end if with a little more effort you can make a engine/program that runs faster? OH, MY, SOMEONE HELP! GOTO WWW.FUNCORP.CJB.NET
Advertisement
in C++ structs and classes are the exact same thing. With the only difference being that the default access-modifier of structs is public while it is private for classes.

regular class-methods are not slower to call than to call a function and pass a pointer to a struct as a parameter (as that''s how they are implemented). Actually classes might be a bit faster, because the class-pointer is passed in a register while a struct-pointer would be passed on the stack to a regular function.

virtual class-methods however are a bit slower than regular functions, because of one extra pointer-dereference. This should however be negligible unless your method is extremely small (a few instructions or so).
Why would you program in C? Machine language is faster.

BTW, feel free to join my procedural language fan club at:

www.dinosaurs.com

alternate link at:

www.VIC20ROOLZ.com




As classes are most often used the equivalent in C would be a structure and a series of functions that take a pointer to that structure as their first arguement. There is no performance differance between C++ and doing the same thing in C. With something like MFC versus straight Windows calls it can be slower, but that is because of all the error checking as well as checking if you used this option or that. That has nothing to do with C++ other than that it uses classes which means it only works under C++. If you wrote the equivalent in C it wouldn''t run any faster. All C++ does is provide you a formal way to do the same thing you could do in C. All it does is save you some coding and makes your programs easier to read. Chances are that how C++ does a particular OOP feature is more effecent than what you would have coded left to your own creativity.
Keys to success: Ability, ambition and opportunity.
quote:Original post by Sydan

Why would you program in C? Machine language is faster.


Sydan,
In response to your challenge before you deleted it, here:

VectorLerp (ClrYellow, ClrRed, 0.6, Sun.Material.Color);

So there.



_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
Silly me, I thought it was a serious post. I think you should skip using an assembler or compiler and just poke opcode and operands into memory then run it.
Keys to success: Ability, ambition and opportunity.
good god. who cares if one is a little faster than the other? unless you run a 386 you shouldn''t be able to tell a speed difference.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Well, I''m using a 486/66 . . . but then again, I''m still in school; when I start my career, I''m gonna get a good computer. Then I can really get involved in real game programming. Right now, I just fiddle around here and there.


"Science is a tool. If the tool works, we use it. If it''s true, that''s great, but if it isn''t, it doesn''t matter" -- ("Desert Fox" from GameDev.net)''s physics teacher
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away"--Henry David Thoreau
just a small point, lilbuddywiser, an oversight...

passing an explicit "this" pointer, ala a struct and functions, would take longer because it''s passed on the function''s stack, where as the implicit this pointer, ala a class and member functions, is passed in a register...


no biggie, just a formality.


sorry, i know you are wise, i just thought it''d be funny to catch one of the big guys

-succinct
-- Succinct(Don't listen to me)
SO in the end........

Theyre ususally isnt a difference in seed between struct and class unless virtual is used. And class might actually be faster in some cases.

and CobraA1 is in serious need of a comp, YOU CAN ATLEAST BUY A P 200 FOR LIKE $150 at a computer sale!

GOTO WWW.FUNCORP.CJB.NET

This topic is closed to new replies.

Advertisement