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,d2fe8ae54035f25f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.91.114 with SMTP id cd18mr9362796wib.2.1356737224533; Fri, 28 Dec 2012 15:27:04 -0800 (PST) Path: i11ni326017wiw.0!nntp.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!87.79.20.101.MISMATCH!newsreader4.netcologne.de!news.netcologne.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 29 Dec 2012 00:27:03 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: A couple of quick questions References: <195201b7-c447-4580-aeb4-1c2329ee45e0@googlegroups.com> <0387724a-7fd2-4317-ba16-d3322dd0fdec@googlegroups.com> In-Reply-To: <0387724a-7fd2-4317-ba16-d3322dd0fdec@googlegroups.com> Message-ID: <50de2ac7$0$6576$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 29 Dec 2012 00:27:04 CET NNTP-Posting-Host: a0445b3c.newsspool3.arcor-online.net X-Trace: DXC=O:df6fYX]e>_A0jCfgHO6>McF=Q^Z^V384Fo<]lROoR18kFejV8B64BN^lB``2dUP6;KRA4l: X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-12-29T00:27:04+01:00 List-Id: On 28.12.12 21:28, Dufr wrote: > Is the efficiency of the compiled code by penalized in any way by the putative bloat of the language? No, usually, the language's features do not adversely affect performance. This might be expected from a language that was required to be suitable for hard real-time processing (hence cannot require huge amounts of memory or processing power). One might instead argue that its features contribute information useful to optimizing compilers. (C's restrict keyword was added to C to allow programmers to provide such information. OTOH, note that Ada has always required that aliased objects be declared aliased.) One noteworthy exception is overflow checking for arithmetical operations. Its absence from C programs is a typical cause of vulnerabilities every other week, which see. But these checks are expensive and could therefore be turned on for sections of an Ada program as needed. (I should hope they do that.) For an example of a program that uses many of Ada's features, yet is really fast (possibly because it does!), see http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=chameneosredux IIRC the wikibook on Ada Programming has examples of executable file sizes in typical Unix installations; they are about the same as file sizes of C programs. Size is a consequence of linking libraries, or linking a small or large run-time system. Object code size is typically the same as for other languages in case optimization is turned on, and even when some checks are on. Here is an example to demonstrate the effect. The same program is written in C, and in Ada, compiled by the same GCC, using the same switches (note that only default checks are on for the Ada program): $ gcc -c -O2 adaex.adb $ gnatchop -r -w adaex.ada && gcc -c -O2 adaex.adb The assembly listings are appended to the source text, to show the extent of difference, if any. #include typedef int16_t num; num Cex(num a, const num b, const num eps) { num result = b - a; while (result > eps) { a += result / 2; result = b - a; } return result; } package Adaex is type Num is range -(2**15) .. +(2**15)-1; function Ex(A, B : Num; Eps: Num) return Num; end Adaex; package body Adaex is function Ex(A, B : Num; Eps: Num) return Num is Copy : Num := A; Result : Num := B - A; begin while Result > Eps loop Copy := Copy + Result / 2; Result := B - Copy; end loop; return Result; end Ex; end Adaex; $ otool -tv cex.o cex.o: (__TEXT,__text) section _Cex: 0000000000000000 movl %esi,%eax 0000000000000002 movl %edi,%ecx 0000000000000004 movl %edx,%r9d 0000000000000007 subl %edi,%eax 0000000000000009 movl %esi,%r8d 000000000000000c cmpw %dx,%ax 000000000000000f jle 0x00000038 0000000000000011 nopl 0x00000000(%rax) 0000000000000018 nopl 0x00000000(%rax,%rax) 0000000000000020 movl %eax,%edx 0000000000000022 shrw $0x0f,%dx 0000000000000026 addl %edx,%eax 0000000000000028 sarw %ax 000000000000002b addl %eax,%ecx 000000000000002d movl %r8d,%eax 0000000000000030 subl %ecx,%eax 0000000000000032 cmpw %eax,%r9d 0000000000000036 jl 0x00000020 0000000000000038 repz/ret $ otool -tv adaex.o adaex.o: (__TEXT,__text) section _adaex__ex: 0000000000000000 movl %esi,%eax 0000000000000002 movl %esi,%ecx 0000000000000004 movl %edx,%r8d 0000000000000007 subl %edi,%eax 0000000000000009 cmpw %dx,%ax 000000000000000c jle 0x00000027 000000000000000e nop 0000000000000010 movl %eax,%edx 0000000000000012 shrw $0x0f,%dx 0000000000000016 addl %edx,%eax 0000000000000018 sarw %ax 000000000000001b addl %eax,%edi 000000000000001d movl %ecx,%eax 000000000000001f subl %edi,%eax 0000000000000021 cmpw %eax,%r8d 0000000000000025 jl 0x00000010 0000000000000027 ret $