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,13c7ec19f3c43155 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: speed of generic code in Ada (vs Java) Date: Wed, 21 May 2008 19:06:32 -0500 Organization: Jacob's private Usenet server Message-ID: References: <9e9bdae7-5e91-4e0c-b783-1ed72311a733@t12g2000prg.googlegroups.com> <2e1de55a-69e5-439e-addc-bde650b4c16a@i36g2000prf.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1211414800 27051 69.95.181.76 (22 May 2008 00:06:40 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 22 May 2008 00:06:40 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 Xref: g2news1.google.com comp.lang.ada:283 Date: 2008-05-21T19:06:32-05:00 List-Id: "Robert A Duff" wrote in message news:wccy7633br3.fsf@shell01.TheWorld.com... > Graham writes: > >> In any case, the 5x comparison sounds extreme and probably comes from >> comparing arrays of ints with something from the Java Collection >> classes, which is a bit like comparing Ada arrays with Ada Containers. > > I don't see why. Ada.Containers.Vectors, for example, does not > introduce an extra level of indirection for each component of the > vector. Ada is more like C++ in that regard. Sorry, but there is no language guarentee of this; it's more that an implementation of Ada.Containers.Vectors does not *have* to have a extra level of indirection. For Janus/Ada, for instance, there would be such an (implicit) indirection coming from the generic code sharing even if there isn't any explicit one. And I'd still expect comparisons to be slower, because the "=" code probably is a loop doing element comparisons (it has to use the formal "=" operator and cannot assume that the actual is the predefined "="). It might be possible for a compiler to optimize that, but it would be pretty complex to do so. (And even "=" for integers has to be done in a loop on some targets -- a bit comparison is not accurate for 1's complement machines, for instance.) The net effect is that generalizations about Ada performance are probably not well-founded. Usually, Ada performance is similar to that of C++, but implementation differences can be a big deal and more different than those between languages. Randy.