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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,92748798eb3c95c4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!feeder2-1.proxad.net!news9-e.free.fr!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Ada has garbage collection References: From: Jean-Marc Bourguet Date: 24 Aug 2004 20:41:44 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <412b8bd4$0$23952$626a14ce@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 24 Aug 2004 20:41:25 MEST NNTP-Posting-Host: 82.254.168.74 X-Trace: 1093372885 news9-e.free.fr 23952 82.254.168.74:33060 X-Complaints-To: abuse@proxad.net Xref: g2news1.google.com comp.lang.ada:2969 Date: 2004-08-24T20:41:25+02:00 List-Id: Wes Groleau writes: > OK, we could argue semantics, but every language with > parameters/data on the call stack has garbage collection > for all those objects. The term has been used in relation with dynamic allocation for so long that I would not be able to hold for that side without feeling that I'm cheating. > And Ada makes it far less necessary than some languages to > avoid pointers and use locals instead. The major use of GC is not for the cases where Ada allow to prevent dynamic allocation where other languages force its use. > Of course, some problems/data structures almost demand > pointers, but with sensible encapsulation and package > designed, controlled types provide all the GC those things > need. > > How does that differ from C++ destructors? C++ destructors offer exactly the same functionnality as controlled types -- with an added convenience of beeing less heavy (they are available for non tagged types). And there are people in the C++ community holding exactly the same view as you: that GC is not needed because of that. Note that I'm not a strong proponent of GC: I feel it provides the most convenient implementation of shared ownership policies, it doesn't allow to skip the choice of a sensible ownership policy for the problem at hand. Too many proponents of GC seems to argue that shared ownership policy is the only one needed. Constrained by the languages I mainly use (C++ for work, Ada when I've no external constraints), I tend to use design that don't benefit a lot from GC (but I see places where there would be a benefit) and I wonder how my design would change if I became used to a language with GC. > Java couldn't afford to be without universal GC, because > it makes almost everything on the heap, and allows no > definition of destructors. A static analysis should allow to use stack allocation for most variables where programmers in other languages would have used it. But that's a very weak argument. Not offering explicit stack allocation (along with a Ada's finalization/C++ destructor feature) is, IMHO, one of the mistakes of Java. -- Jean-Marc