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=2.7 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, THIS_AD autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d5b211b0c1ffcf3e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.193.129 with SMTP id ho1mr1680266pbc.8.1339225453129; Sat, 09 Jun 2012 00:04:13 -0700 (PDT) Path: l9ni32770pbj.0!nntp.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 09 Jun 2012 09:04:14 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Practicalities of Ada for app development References: <79c5c9f7-4b72-4990-8961-b3e2db4db79b@qz1g2000pbc.googlegroups.com> In-Reply-To: <79c5c9f7-4b72-4990-8961-b3e2db4db79b@qz1g2000pbc.googlegroups.com> Message-ID: <4fd2f56b$0$6580$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 09 Jun 2012 09:04:11 CEST NNTP-Posting-Host: d2eb1700.newsspool3.arcor-online.net X-Trace: DXC=J@g4O61\Hcb^Y=RbYBPl4`McF=Q^Z^V3h4Fo<]lROoRa8kFejVh6K9Nc=C:50c[GCAk]GnG3b X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-06-09T09:04:11+02:00 List-Id: On 08.06.12 22:48, wrp wrote: > 6. Size and latency are sometimes an issue. I've heard that since GNAT > is oriented to building larger systems, the executables it produces > are comparatively bulky. What is the situation relative to C in that > regard? Diagnoses of relative sizes of executables have frequently neglected the effect of static vs dynamic linking, for example. For the following functions, written in C and Ada, GCC produces sequences of processor instructions that are almost identical: -- 8< -- #include typedef double Real; typedef int32_t Nat; static Nat Last = 42; Real Gen_Random (const Real Max) { #define IM 139968 #define IA 3877 #define IC 29573 Last = (Last * IA + IC) % IM; return (Max * (Real) Last) / (Real) IM; } -- 8< -- package Nothing is subtype Real is Long_Float; function Gen_Random (Max : in Real) return Real; end Nothing; package body Nothing is Last : Natural := 42; function Gen_Random (Max : in Real) return Real is IM : constant := 139_968; IA : constant := 3_877; IC : constant := 29_573; begin Last := (Last * IA + IC) mod IM; return (Max * Real (Last)) / Real (IM); end Gen_Random; end Nothing; -- 8< -- Translations: $ gcc -W -c -O nothing.c $ otool -tv nothing.o # C output _Gen_Random: 0000000000000000 pushq %rbp 0000000000000001 movq %rsp,%rbp 0000000000000004 imull $0x00000f25,0xfffffffc(%rip),%ecx 000000000000000e addl $0x00007385,%ecx 0000000000000014 movl $0x1df75681,%edx 0000000000000019 movl %ecx,%eax 000000000000001b imull %edx 000000000000001d sarl $0x0e,%edx 0000000000000020 movl %ecx,%eax 0000000000000022 sarl $0x1f,%eax 0000000000000025 subl %eax,%edx 0000000000000027 imull $0x000222c0,%edx,%edx 000000000000002d subl %edx,%ecx 000000000000002f movl %ecx,0x00000000(%rip) 0000000000000035 cvtsi2sd %ecx,%xmm1 0000000000000039 mulsd %xmm1,%xmm0 000000000000003d divsd 0x00000023(%rip),%xmm0 0000000000000045 leave 0000000000000046 ret 0000000000000047 nop $ gnatchop -r -w nothing.ada && gnatmake -gnatwa -gnatp -O nothing.adb $ otool -tv nothing.o # Ada output _nothing__gen_random: 0000000000000000 pushq %rbp 0000000000000001 movq %rsp,%rbp 0000000000000004 imull $0x00000f25,0xfffffffc(%rip),%ecx 000000000000000e addl $0x00007385,%ecx 0000000000000014 movl %ecx,%esi 0000000000000016 sarl $0x1f,%esi 0000000000000019 movl %ecx,%eax 000000000000001b xorl %esi,%eax 000000000000001d movl $0x1df75681,%edx 0000000000000022 mull %edx 0000000000000024 shrl $0x0e,%edx 0000000000000027 xorl %edx,%esi 0000000000000029 imull $0x000222c0,%esi,%esi 000000000000002f subl %esi,%ecx 0000000000000031 movl %ecx,0x00000000(%rip) 0000000000000037 cvtsi2sd %ecx,%xmm1 000000000000003b mulsd %xmm1,%xmm0 000000000000003f divsd 0x00000011(%rip),%xmm0 0000000000000047 leave 0000000000000048 ret While not identical, and while the Ada option -gnatp suppresses all checks in order to compete with C on a size scale, this ad hoc test demonstrates the extent to which there is support for saying an Ada executable will be "bulky", I think.