From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!mcvax!hafro!krafla!snorri From: snorri@rhi.hi.is (Snorri Agnarsson) Newsgroups: comp.lang.ada Subject: Re: Garbage Collection Message-ID: <692@krafla.rhi.hi.is> Date: 28 Dec 88 16:09:19 GMT References: <3985@hubcap.UUCP> Organization: University of Iceland List-Id: >From article <3985@hubcap.UUCP>, by billwolf@hubcap.clemson.edu (William Thomas Wolfe,2847,): > When there is great difficulty deciding whether a given object > exists or not, the maintainer experiences great difficulty > pinning down the precise state of the program. Exactly - and garbage collection is precisely what you need to get rid of this difficulty. When you have garbage collection there is no difficulty in determining whether an object exists or not. It exists if you have some way to refer to it, otherwise not. > DESTROY procedures are easy to write, need only be written once > per ADT, and can be reused indefinitely. GC costs us the > computer time required to repeatedly determine which storage > is in use and which is not, and this cost must be paid repeatedly > AT RUN TIME. Given that this PERMANENT, RUN_TIME COST can be > avoided by simply communicating the fact that a particular object > is no longer needed, GC is a rather costly crutch for lazy programmers. The PERMANENT, RUN_TIME COST is very often much worse if you use the methods Mr. Wolfe dogmatically demands. For example if you have a program which does calculations with indefinite size integers, then each new integer value computed is most appropriately stored in a new area in the heap. If you disallow sharing then each assignment must create a new area. This is costly. Each time you stop using an integer variable you must deallocate it. This is costly. If you have a simple copying garbage collector and allow sharing, which by the way is not dangerous at all in this case at least, you don't have the abovementioned costly operations, but instead you have a simple garbage collection which will in my experience be infrequent (e.g. every ten seconds for a program doing intensive calculations with 10000 digit integers) and fast (less than a fraction of a second for each collection). And this is on a machine with small memory (a PC with 640KB memory). Memory management is one of the most difficult things for programmers to do correctly and efficiently. Garbage collection certainly takes this burden from the programmer and allows him to think in more abstract terms. In my opinion reusable software components can not be adequately created in languages that do not have good automatic memory management. In this respect Ada is a failure unless garbage collection is required. The C++ approach of using destructors is costly both in memory and time and does not really solve the problem, although it is better than nothing. It is regrettable in my opinion that the issue of garbage collection is so much misunderstood. It is also regrettable that proponents of the various interesting new programming methodologies do not push garbage collection as an issue. Functional programming, logic programming and object oriented programming have only one thing in common; reliance on garbage collection. None of those methodologies would have much use in my opinion if it were not for garbage collection. And, I repeat: reusable modules (that includes generic packages) are almost useless in languages with no garbage collection compared to the use you can get in languages having garbage collection. -- Snorri Agnarsson -- snorri@rhi.is Raunvisindastofnun Haskolans Dunhaga 3 IS-107 Reykjavik ICELAND