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-Google-Thread: 103376,2a34b7ad6c6a0774 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!d8g2000yqf.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers Date: Fri, 6 Aug 2010 16:14:21 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 174.28.246.148 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1281136462 26650 127.0.0.1 (6 Aug 2010 23:14:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 6 Aug 2010 23:14:22 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d8g2000yqf.googlegroups.com; posting-host=174.28.246.148; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET CLR 4.0.20506),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12918 Date: 2010-08-06T16:14:21-07:00 List-Id: On Aug 6, 2:21=A0pm, Elias Salom=E3o Helou Neto wrote: > I would like to know how does code generated by Ada compilers compare > to those generated by C++. I use C++ for numerical software > implementation, but I am trying to find alternatives. One thing, > however, I cannot trade for convenience is efficiency. Will Ada > compiled code possibly be as efficient as that generated by C++ > compilers? > > Also, I do need to have something similar to C++ "templated > metaprogramming" techniques. In particular, C++0x will introduce > variadic templates, which will allow us to write templates that will > generate efficient, type-safe, variable-argument functions. Is there > anything like that in Ada? > > If any of the above questions is to be negatively answered, I ask: why > does Ada even exist? And further, is there any language which is > _truly_ better (regarding code maintainability, readability and > developing ease) than C++ and as overhead-free as it? > > Thank you in advance, > Elias. Well, it really depends on what you mean by "efficient." If you're terming things like accessing invalid indecies of arrays as 'efficient' "because there's no time wasted on range-checking" then you're *REALLY* in the wrong place... however, if you're terming 'efficient' as there are no range-checks generated because the variable indexing the array is constrained to valid values, well then you'd be quite welcome here. {GCC has an Ada front-end, so in-theory Ada and C++ gcc-compiled programs should have very-near the same profiles; this is, however, not taking into any consideration for Ada's stronger type-system and impacts of compile-time checks & optimizations that allows.} As for me, I am rather strongly opinionated that things like range-checking should [always] be done, unless there is some VERY compelling and definable reason not to. {Say you're making a Stream-interpreter where the stream is operation-instructions for some robotic component, except the stream itself also contains control-commands for sub- unit[s] that have a different/larger/disjoint range.} Templates, as I understand them in C++ are roughly analogous to Ada's generic-system; I never got into C++'s templates and am relatively new to Ada, so I'll let someone with more experience address that aspect.