home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!utcsri!skule.ecf!torn!nott!cunews!revcan!software.mitel.com!kim!kim
- From: kim@Software.Mitel.COM (Kim Letkeman)
- Newsgroups: comp.lang.pascal
- Subject: Re: BP/TP OOP is missing something...
- Message-ID: <KIM.92Nov18085152@kim.Software.Mitel.COM>
- Date: 18 Nov 92 13:51:52 GMT
- References: <KIM.92Nov16125141@kim.Software.Mitel.COM>
- <1992Nov17.153804.21729@news.clarkson.edu>
- <dmurdoch.282.722020256@mast.queensu.ca> <10773@vice.ICO.TEK.COM>
- Sender: kim@Software.Mitel.COM
- Organization: MITEL Public Switching, Kanata, Ontario, Canada
- Lines: 75
- In-reply-to: bobbe@vice.ICO.TEK.COM's message of 17 Nov 92 21:08:27 GMT
-
- In article <10773@vice.ICO.TEK.COM> bobbe@vice.ICO.TEK.COM (Robert Beauchaine) writes:
-
- | This whole topic falls under the scope of garbage collection,
- | which is considered by many programmers an extremely important
- | part of a language. And pascal already does it all the time
- | anyway. What happens to the local variables allocated on the
- | stack when a function begins or ends? They are created/destroyed
- | by the compiler, which knows knows exactly how to perform these
- | tasks.
-
- Um ... garbage collection is a wholly different concept from local
- stack variables. The compiler does not really create or destroy these
- variables, it just moves a stack pointer. If you want a variable to be
- initialized on entry, you still have to do it yourself. Locals don't
- normally require destruction, but if they did you would have to do it
- yourself as well.
-
- There is no useful analogy between construction and destruction of
- atomic (i.e. trivial) variables and objects.
-
- | The only difference between objects and the predefined data types
- | is that *you* have to tell the compiler exactly how to build or
- | get rid of the objects. You should not have to tell the compiler
- | _when_ to do so. It seems to me the current object
- | construction/destruction methodology is the departure from the
- | norm.
-
- What norm? There lots of competing philosophies and languages and all
- are quite different and equally main stream based on number of users.
- And only very few have any garbage collection at all.
-
- For example, in Actor (a very pure Smalltalk-derived OOP language),
- you can simply reuse an object reference and, if that was the last
- reference to the previously pointed to object, it is automatically
- (read: incrementally) garbage collected for you. The memory is
- reclaimed and reused.
-
- BUT: if there is a destructor, then you have to call it yourself. I
- expect that smalltalk is like this as well.
-
- The point being that C++ does not have any real garbage collection at
- all. It does not even have reference counting collection, where
- destructors are called only if there are no references to them. This
- can be built into a base object, but is not truly workable without
- serious compiler support. And neither TP nor C++ can provide that
- support because of their free-wheeling use of pointers.
-
- For further information you should check out Betrand Meyer's Object
- Oriented Software Construction. His Eiffel language probably has one
- of the better schemes.
-
- | This is exactly why I like the C++ approach. With automated
- | construction/destruction, operator overloading, etc, objects are
- | much more seamlessly integrated into an application as extensions
- | of the basic data types. Once the class is properly defined, the
- | programmer never has to consider the objects as anything except
- | predefined atomic stuctures again.
-
- As soon as you allow multiple inheritance and such, you have to
- potential for a class to break any time a new full build is done. You
- can only treat objects as unchanging entities if they are relatively
- trivial. Any complex system is constantly evolving and so are its
- objects.
-
- There's no free lunch. C++ does a lot for you, but you assume a lot of
- other burdens for that pleasure. You must now ensure that objects are
- compatible with each other in all possible combinations or you'll end
- up with complex and hard to debug errors. You must ensure that local
- objects are not added to collections or you'll leave dangling
- references all over the place. And so on.
-
- TP's simplicity is one of its great strengths. And probably one of
- the reasons why C++ didn't wipe it out long ago ....
- --
- Kim Letkeman kim@Software.Mitel.COM
-