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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3ccb707f4c91a5f2 X-Google-Attributes: gid103376,public From: nasser@apldbio.com Subject: Re: Java vs Ada 95 (Was Re: Once again, Ada absent from DoD SBIR solicitation) Date: 1996/10/20 Message-ID: <54el0r$pvf@lex.zippo.com>#1/1 X-Deja-AN: 190895140 references: <325BC3B3.41C6@hso.link.com> <325D7F9B.2A8B@gte.net> organization: Perkin-Elmer newsgroups: comp.lang.ada Date: 1996-10-20T00:00:00+00:00 List-Id: In article , kst@thomsoft.com says... > >In another article, Robert Dewar wrote, "The whole point of gc is that >it has no semantics, it is transparent!" I don't think that's quite >true either. For example, consider the following Ada program: > > with System; > with Ada.Text_IO; use Ada.Text_IO; > procedure GC_Test is > type Pointer is access Integer; > P : Pointer; > begin > for I in 1 .. System.Memory_Size loop > P := new Integer; > end loop; > Put_Line("The system has garbage collection"); > exception > when Storage_Error => > Put_Line("The system does not have garbage collection"); > end GC_Test; > >For simplicity, I've assumed here that System.Memory_Size fits in an >Integer and that the compiler doesn't optimize out the allocation in >the loop; there are ways around that. > >It's true that garbage collection is semantically transparent for >well-behaved programs (i.e., ones that wouldn't otherwise run out of >memory and don't try to play certain nasty tricks). > Are you saying that the compiler will generate code (assuming GC is supported) to free the memory pointed to by P before it does the next allocation? (that's why the program does not run out of memory in this loop). To me, this program is an erroneous program to start with. Having GC will only HIDE this fact. So having GC seems not such a good idea, since programmers will start writting sloppy code saying the GC will take care of the memory. So, based on this new radical point of view of mine, I would say that a well written program should not need GC. If each function/package cleans after itself, and the programmer is careful, then there is no need for GC. Programs that have memory leakage are programs that defective, and so one should fix them, GC is not the solution, the solution is to go fix the code itself instead, wich would eleminate the need to having GC to start with. Here, I just solved this GC issue once and for all. Nasser