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.5 required=5.0 tests=BAYES_00,INVALID_MSGID, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,3ccb707f4c91a5f2 X-Google-Attributes: gid103376,public From: kst@thomsoft.com (Keith Thompson) Subject: Re: Java vs Ada 95 (Was Re: Once again, Ada absent from DoD SBIR solicitation) Date: 1996/10/14 Message-ID: #1/1 X-Deja-AN: 189375368 sender: news@thomsoft.com (USENET News Admin @flash) x-nntp-posting-host: pulsar references: <325BC3B3.41C6@hso.link.com> <325D7F9B.2A8B@gte.net> organization: Thomson Software Products, San Diego, CA, USA newsgroups: comp.lang.ada originator: kst@pulsar Date: 1996-10-14T00:00:00+00:00 List-Id: In jsa@alexandria (Jon S Anthony) writes: [...] > But *languages* don't have GC. Implementations of them do. Even > Meyer says little about GC in ETL - just that all *implementations* > are *expected* to have it. That's not *quite* correct. It's admittedly difficult to define garbage collection in a formal language definition, but the Java definition at least attempts to do so. Here's paragraph 20.16.9 of The Java Language Specification, version 1.0 (available at ). 20.16.9 public void gc() Calling this method suggests that the Java Virtual Machine expend effort toward recycling discarded objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to recycle all discarded objects. (The name gc stands for "garbage collector.") The Java runtime system will perform this recycling process automatically as needed, in a separate thread, if the gc method is not invoked explicitly. See also the method gc (�20.18.12) of class System, which is the conventional and convenient means of invoking this method. This does refer to the "Java Virtual Machine", but I don't think there's any requirement that the JVM be implemented via the usual byte code interpreter. Even for a Java compiler that generates machine code directly, the runtime system has to provide a JVM implementation as specified in the language specification. I think. I don't believe that Java even defines a way to explicitly deallocate a specified piece of memory, like Ada's Unchecked_Conversion or C++'s free(). The Eiffel language definition recommends garbage collection but does not mandate it. As far as I know, all existing Eiffel implementations do provide automatic garbage collection. 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). -- Keith Thompson (The_Other_Keith) kst@thomsoft.com <*> TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706 FIJAGDWOL