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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:1604:: with SMTP id 4mr9233622iow.245.1560267558954; Tue, 11 Jun 2019 08:39:18 -0700 (PDT) X-Received: by 2002:a9d:32a6:: with SMTP id u35mr35730898otb.81.1560267558797; Tue, 11 Jun 2019 08:39:18 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!g15no198435itd.0!news-out.google.com!l135ni407itc.0!nntp.google.com!s188no199456itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 11 Jun 2019 08:39:18 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=50.66.161.135; posting-account=lzqe5AoAAADHhp_gregSufVhvwu22fBS NNTP-Posting-Host: 50.66.161.135 References: <28facad3-c55f-4ef2-8ef8-004925b7d1f1@googlegroups.com> <87woi0xtwm.fsf@nightsong.com> <4a0438de-1f1d-4469-aae4-908854d378ea@googlegroups.com> <47d02bdc-6b50-43aa-bc5d-bb5b6225f5bd@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4516d350-0076-4dc7-b482-87d5693d3977@googlegroups.com> Subject: Re: Why .ads as well as .adb? From: Brad Moore Injection-Date: Tue, 11 Jun 2019 15:39:18 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 4925 X-Received-Body-CRC: 2757151988 Xref: reader01.eternal-september.org comp.lang.ada:56611 Date: 2019-06-11T08:39:18-07:00 List-Id: So far, the discussion has largely attempted to compare the approaches usin= g very abstract analogies, without specific examples (eg books vs software = programs). I think it its probably a good idea to compare some real examples. Consider a java class from an example of the n-body problem from the Comput= er Benchmarks Game website; See https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbo= dy-java-5.html For the comparison, examine the NBodySystem class, which is the bulk of the= example, which appears to be a well written java program. Imagine someone handed you this class and you asked you to write a program = that uses it. It takes a bit of reading to pull out the important parts, ju= st to figure out how to use the class. Someone shouldn't have to wade throu= gh pages of implementation to figure out how to use the class. This simulat= ion only has data for four planets. Imagine if it were modelling considerab= ly more objects (asteroids, etc) in the solar system. There could be a lot = of data to wade through, not to mention code. This is still a pretty simple= program, classes in the real world often can be a lot more complex with la= rger implementations.=20 If I were to directly translate that class into Ada, though, I'd likely end= up with something like the following package specification. -- Simulates orbits of the Jovian planets using a simple symplectic-integr= ator -- package N_Body_System is procedure Reset_Simulation; =20 procedure Advance (dt : Duration); =20 function Energy return Long_Float; end N_Body_System; Although in Ada I'd want to also define a suitable type for the return obje= ct of the Energy function that would describe the units of result. I cannot= easily tell by looking at the java example what the units are, and didn't = bother digging in to find out. Of course, comments would also be helpful. Because the N_Body_System is a singleton class in Java, there's no need to = create an object for it in Ada, all the implementation details can be place= d in the body of the package. Rather than a constructor as in Java, I provided a Reset_Simulation call, i= n case someone wanted to rerun the simulation more than once (perhaps to me= asure a performance average) To me, this provides a much simpler view for the client programmer. One can= likely write a program to run the simulation without even looking at the i= mplementation. If someone wants to understand the implementation, they can = look at that if they really want to. I feel that having the language encour= age you to intermix the specification and implementation together is really= unappealing, from a system engineering point of view, in my opinion. Brad