| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | C++ Question |
Hello Tom! 21 Jan 96 02:01, Tom Brown wrote to All: TB> I have been using C++ for some time now. As a long-time C TB> programmer, TB> I don't use the object oriented features as much as I might. It TB> seems as though a simple program with no templates, OpenClass TB> objects or containers comes out much larger than it ought to. Ah... but it does come out that big, and you're lookin' for reasons, right? :-) TB> What I like most about the language is the way it lends itself to TB> grouping related functions. My code looks like C code except I TB> do use cout and cerr all of the time. I've often wondered why a TB> simple program with a main() and one object with four methods TB> (functions to me) needs to be 40K when the same thing in C comes TB> in at 14K. I don't mean a similar thing in C. If you take the TB> C++ object and simply break it down into the four functions and TB> compile the whole works as C code, it comes in a bunch smaller. TB> The size increase with C++ starts with larger .OBJs and more TB> run-time code is linked in, as well. C++ has more runtime checking. Objects also use more runtime checking than non-objects, ESPECIALLY once you put a single 'virtual' function in! It has much checking of the pointers to figure out if this is a base object, or a derived object, and how many derivations it has gone through and... well... this happens at link time sometimes, and runtime other times. TB> I know that with C, I need to keep each function in it's own TB> source file so that the linker can link in only the functions TB> that it needs. I'm talking about object libraries specifically. TB> C++ seems to get out of hand if you put each method into it's own TB> source file. I've got some pretty big objects (all in one source TB> file -> a .CPP and a .HPP), TB> so I'm guessing that if I instantiate one of these bad boys I get TB> the whole thing regardless of what methods are called in my TB> application. I was under the opposite impression, since I know not all of the main C libraries are compiled into my executables... :-/ TB> Curiously, I find the performance of C++ to be very near C when I TB> don't use C++ specific features, even though the .EXEs are TB> larger. I TB> don't care about hard disk space, but I would like to code as TB> efficiently as I can. When speed becomes a problem, concentrate on that area. If you find a function eating way too much time, first try getting it into another thread. If it is still killing your CPU, or you cannot change threads (such as anything I write - I haven't figured out all the proper stuff yet ), hand-tune the routine via inline assemebly. Otherwise, don't worry about it... :-) We all have 33 million cycles every second or more, so another 100 isn't going to kill anyone. BTW, this is more of a C++ question, and maybe should be taken to C_PLUSPLUS instead. Darin McBride --- GoldED/2 2.42.G0614* Origin: Tanktalus' Tower BBS/RPGs Galore! (1:342/708) SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809 @PATH: 342/708 5015 61 3615/50 396/1 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.