MY GOD, Does C++ suck?
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
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).
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
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.
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.
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.
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
JoeMont001@aol.com www.polarisoft.n3.net
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
"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
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement