From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: "Douglas A. Gwyn" Message-ID: <3C1A4F75.B700F30F@null.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit References: <20011213190251.3117F199BB@mail.cse.psu.edu>, <9vdbj1$ehk$2@ctb-nnrp1.saix.net> Subject: Re: [9fans] pascal, TeX Date: Mon, 17 Dec 2001 10:14:41 +0000 Topicbox-Message-UUID: 37bb7100-eaca-11e9-9e20-41e7f4b1d025 D De Villiers wrote: > According to my knowledge - Java was the first language that implemented > garbage collection...Neather C/C++ or Pascal (Delphi etc) have garbage > collection and memory must be manually located/delocated etc. Actually, garbage collection was implemented in some very old languages such as LISP. C++ does have what amounts to garbage collection plus other programmer-controllable actions in its object destructors, which are automatically invoked when objects go out of scope. C has had garbage collectors implemented for it; for example, somebody (I think it was Rob) made heavy use of gcalloc() in the Blit family, both in the terminal's operating system and in application programs. The basic problem with garbage collection in C is nt in doing it, but in doing it efficiently. The main reason it is hard is that C has excellent support for pointer arithmetic, so a program can manufacture valid pointers in ways that are hard to track, and a garbage collector can't (with a reasonable amount of work) be sure when there is no pointer remaining that could be used to access an object. Nevertheless, there have been some clever "good enough" garbage collectors designed for use with C. It's not obvious that they are needed, since C has a long heritage of the programmer making explicit calls to free() to deallocate dynamic objects.