Classes Vs. Straight Code

Started by
91 comments, last by farmersckn 23 years, 9 months ago
Alright, which is faster, using classes, or using straight code? I''m not talking about using MFC to write a game or anything, cuz I know that hardly anyone does that. But isn''t it just that little bit slower because you have to pass the ''this'' pointer to every method? Another thing, is it really as easy to write a program using classes as it is to write code like you would in C? Or is it easier? farmersckn Sometimes even chickens need to eat... Don't bang your head against a wall just to enjoy the good feeling when you stop.
Yesterday is the past, tomorrow is the future. Today is a gift, that is why we call it the present.
Advertisement
1. It''s slower, but by such a small amount it''s virtually negligible.
2. I personally think it''s a little easier to write games with classes.

Plus, Worms Armaggeddon was written with MFC! They must have some incredible programmers at Team 17.

lntakitopi@aol.com | http://geocities.com/guanajam/
''C'' may be a bit faster but working with classes is a lot easier. As to the MFC, i wouldn''t make a game with it but i have made some 3D programming tools with it and have experienced no performance penalties. MFC is simply a thin wrapper around the Win32 API.



ECKILLER
ECKILLER
Wait until MadKeithV comes around... He''ll make everything clear to you!
> which is faster, using classes, or using straight code?

Impossible to answer. :-)

> But isn''t it just that little bit slower because you have to pass the ''this'' pointer to every method?

If you don''t use classes (and thus the hidden "this" pointer), you''d end up having to dereference a pointer, or pass an extra pointer yourself anyway. Besides, if passing an additional single pointer is producing a significant slow-down in performace, something''s wrong with your design. Or try inline. :-)

> Another thing, is it really as easy to write a program using classes as it is to write code like you would in C? Or is it easier?

I used to be an "only C" programmer. When I started learning C++, it took me a couple months to really get the hang of things. Now, for me, I have trouble thinking of how to approach a programming problem *without* using classes. But that''s the nice thing about C++ - as you''re learning it, you can still use as much "only C" as you want to minimize the learning curve.

the Gent
aig
I personally don''t like over doing classes. Sure they r cool, but not for everything like a CApp. I love nice clean C code (i usually compil as cpp tho ), its so nice to look at! The speed diff is almost nothing tho.

quote:
from ECKILLER
''C'' may be a bit faster but working with classes is a lot easier.


IMO, if you have well designed C app its just as easy...



-----------------------------
-cow_in_the_well

http://cowswell.gda.ods.org/

- Thomas Cowellwebsite | journal | engine video

Which is faster? Hmm, depends. That''s a loaded question. Questions that come to mind is:

How long will it take to make it procedural top down? Object Oriented?

How easy will it be to maintain?

How easy will it be to integrate new concepts in?

Most importantly, will it get finished top-down or OO?

Just because it''s C++ doesn''t mean everything has to be a class either by the way. Use what works for you on the situation at hand, that''s what I would say.

YAP YFIO,
deadlinegrunt

~deadlinegrunt

quote:Original post by deadlinegrunt

Just because it''s C++ doesn''t mean everything has to be a class either by the way


I know that, and as I said I compile using the CPP compiler in MSVC rather than the C, so i can take advantage of keywords such as new and delete. I just don''t like the over usage of classes some people use. (ie. u don''t need classes on things u don''t need multiinherited (such as the CApp example)).





-----------------------------
-cow_in_the_well

http://cowswell.gda.ods.org/

- Thomas Cowellwebsite | journal | engine video

C & C++ 'speed' is the same.
It is what you use, do not use, or simulate that makes the difference.

If you use a table of function pointers in C, you may as well use a C++ class. If you use name-mangling in C, you may as well use Operator overloading in C++.

If you're not maxing out the computing power of the machine; there's no need to optimize.


Edited by - Magmai Kai Holmlor on June 28, 2000 9:54:37 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Well, I don''t know too much about C++, but I prefer straight C. There are some nice things about C++, such as operator overloading and `new'' and `delete'', but I don''t think classes are as useful as everyone makes them out to be. How often would one need multiple instances of a module, anyway? What the heck is the difference between w_move(win, x, y) and win->move(x, y)? Besides the fact that the latter is slower?

I have a sneaking suspicion that all that is the stuff mindless babbling rants are made of, not solid code. So it depends on what your goal is: to babble about your `superior'' methodologies, or to simply wallop the snot out of the competition.

Now, now. I don''t mean to insult anyone. It''s just that I''ve taken way too much C-is-insufficient-for-Real-Programs hogwash.

This topic is closed to new replies.

Advertisement