BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OOP and large EXEs
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Non-Technical
View previous topic :: View next topic  
Author Message
Jud McCranie
Guest





PostPosted: Tue Sep 16, 2003 3:39 am    Post subject: OOP and large EXEs Reply with quote



Is is correct that with an OOP language (such as Delphi or C++), the linker
can't remove the unused code the way the linker with Turbo Pascal could?

Can you give me a reference?

Thanks very much.


Back to top
herman
Guest





PostPosted: Tue Sep 16, 2003 4:36 am    Post subject: Re: OOP and large EXEs Reply with quote




"Jud McCranie" <judmccr (AT) bellsouth (DOT) net> 写入消息新闻
:3f6685ca$1 (AT) newsgroups (DOT) borland.com...
Quote:
Is is correct that with an OOP language (such as Delphi or C++), the
linker
can't remove the unused code the way the linker with Turbo Pascal could?

Can you give me a reference?

Thanks very much.


the linker can remove unuesed global variables/procedures, but without class

members.



Back to top
Jud McCranie
Guest





PostPosted: Tue Sep 16, 2003 4:43 am    Post subject: Re: OOP and large EXEs Reply with quote



Quote:
the linker can remove unuesed global variables/procedures, but without
class
members.

Thanks. Can you clarify what you mean by "without class members" foe me?

Can/does it remove unused methods of an object?




Back to top
Cruxy
Guest





PostPosted: Tue Sep 16, 2003 6:21 am    Post subject: Re: OOP and large EXEs Reply with quote

Quote:
Thanks. Can you clarify what you mean by "without class members" foe me?

Can/does it remove unused methods of an object?

hi,

No. A object is also known as class and all (unused) methods in an object
are not removed on optimization.

greetz


Back to top
Dave Nottage (TeamB)
Guest





PostPosted: Tue Sep 16, 2003 6:33 am    Post subject: Re: OOP and large EXEs Reply with quote

Cruxy wrote:
Quote:
A object is also known as class..

An object is not a class. An object is an instance of a class.

Quote:
and all (unused) methods in an object are not removed on
optimization.

All unused non-virtual methods of a class are removed by the linker.

--
Dave Nottage (TeamB)



Back to top
Dzmitry Piatrushenia
Guest





PostPosted: Tue Sep 16, 2003 7:07 am    Post subject: Re: OOP and large EXEs Reply with quote

Hello Jud McCranie,

Quote:
Is is correct that with an OOP language (such as Delphi or C++), the linker
can't remove the unused code the way the linker with Turbo Pascal could?

The linker can remove unused code if it is REALLY unused. For example,
code in the initialization section of the unit isn't explicitly used,
but it can't be removed. So if you simply add a unit into the
USES-clause and don't use any of its code, your EXE file will grow anyway.
--
Dzmitry Piatrushenia
ICQ #48665143


Back to top
Jeremy Collins
Guest





PostPosted: Tue Sep 16, 2003 7:27 am    Post subject: Re: OOP and large EXEs Reply with quote

Cruxy wrote:


Quote:
No. A object is also known as class and all (unused) methods in an object
are not removed on optimization.

An object is an *instance* of a class - they are different things.

--
jc

Remove the -not from email


Back to top
Cruxy
Guest





PostPosted: Tue Sep 16, 2003 10:44 am    Post subject: Re: OOP and large EXEs Reply with quote

Quote:
An object is not a class. An object is an instance of a class.
Thanks, now I also know the exact explanation of classes and objects Wink!


Quote:
All unused non-virtual methods of a class are removed by the linker.
Also if these are public/published members of a class? (cause there might

be some problems on passing references from objects)


Back to top
Kristofer Skaug
Guest





PostPosted: Tue Sep 16, 2003 11:13 am    Post subject: Re: OOP and large EXEs Reply with quote

"Jud McCranie" wrote
Quote:

Can/does it remove unused methods of an object?

At the very least, the compiler will give a hint about unused *private*
methods of a class.

Kristofer




Back to top
Andrea Raimondi
Guest





PostPosted: Tue Sep 16, 2003 12:10 pm    Post subject: Re: OOP and large EXEs Reply with quote

Dzmitry Piatrushenia wrote:
Quote:
The linker can remove unused code if it is REALLY unused.

Better to say that the linker can remove all unused code that it can
delete *safely*.

Andrew




Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Tue Sep 16, 2003 2:56 pm    Post subject: Re: OOP and large EXEs Reply with quote

Cruxy wrote:
Quote:

All unused non-virtual methods of a class are removed by the linker.
Also if these are public/published members of a class? (cause there
might be some problems on passing references from objects)

Within an .exe, yes - the linker can determine whether these are referred to
anywhere. If compiling a package, then no because the linker cannot predict
whether these will be referred to by .exes using the package. That's why
VCLxx.BPL is so large compared to the size of an exe compiled without
packages.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson



Back to top
Jud McCranie
Guest





PostPosted: Tue Sep 16, 2003 4:14 pm    Post subject: Re: OOP and large EXEs Reply with quote

Quote:
Within an .exe, yes - the linker can determine whether these are referred
to
anywhere. If compiling a package, then no because the linker cannot
predict
whether these will be referred to by .exes using the package. That's why
VCLxx.BPL is so large compared to the size of an exe compiled without
packages.

Thanks.

As a test, I added an unused proc to a form of mine. If I put the
declaration in the private section, it did not increase the size of the EXE.
But if I put it above the privae section under class, it DID increase the
EXE, even though it is never used. Why is that?




Back to top
Jud McCranie
Guest





PostPosted: Tue Sep 16, 2003 4:54 pm    Post subject: Re: OOP and large EXEs Reply with quote

Thanks for the replies everyone, I'm still trying to understand it.

I did my test of adding an unused proc, and it did increase the size of the
EXE if I put it under Class.

Also, http://www.clarionmag.com/col/97-07-whyoop.html says

"With our smart linker technology, we do not copy objects or classes as with
other languages. We avoid linking in methods that are not used. This allows
you to use pieces of a complex object. Other languages suffer horrible bouts
of code bloat."

Doesn't that imply that unused methods do get linked in with most OOP
languages? Can someone explain?



Back to top
TObject
Guest





PostPosted: Tue Sep 16, 2003 5:02 pm    Post subject: Re: OOP and large EXEs Reply with quote

Quote:
An object is not a class. An object is an instance of a class.

Instantiated object is an instance of a class. ;)

I guess different people call different things different names...




Back to top
Jud McCranie
Guest





PostPosted: Tue Sep 16, 2003 5:13 pm    Post subject: Re: OOP and large EXEs Reply with quote

Quote:
All unused non-virtual methods of a class are removed by the linker.

What about unused vitrual methods?




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Non-Technical All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.