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.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d575f572a099528 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-03 22:56:09 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!enst!enst.fr!not-for-mail From: "Steven Deller" Newsgroups: comp.lang.ada Subject: RE: What is faster Ada or C? Date: Tue, 4 Dec 2001 01:54:00 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1007448967 68309 137.194.161.2 (4 Dec 2001 06:56:07 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 4 Dec 2001 06:56:07 +0000 (UTC) To: Return-Path: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal In-Reply-To: <3C0C3664.7C3B3927@acm.org> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.6 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:17373 Date: 2001-12-04T01:54:00-05:00 Ada. If written right with a reasonable compiler. I have had many cases where Ada was faster, both at the macro level and the micro level. One macro example -- old UNIX without threads. 50 Ada tasks sharing SIGIO with 50 open TCP-IP connections versus a single C program doing the same thing with a "hand coded" routine to check for I/O completions on SIGIO (actually doing less processing than the Ada version). The Ada version achieved 20% better throughput. In the above, polling was first used in the Ada program. Because the Ada was slow, the customer wrote a C framework that did none of the processing done in the Ada program, but got twice the throughput of the unmodified data. The customer wanted to abandon Ada "because Ada tasking is too slow" and asked for their money back on the compiler. We went in, analyzed the problem using RMA, showed them the problem, provided a "SIGIO distributor" package, changed 10 lines of their application code to eliminate polling and use SIGIO, and got 140% speedup from the original Ada, resulting in 20% more throughput than the simple C program. I could even explain why the Ada version *should* be faster, but that was about 10 years ago. One micro example -- SQRT. Using Apex and Numerics.Generic_Elementary_Functions the SQRT function is faster in Ada than in C on any target system with hardware SQRT. This is because C uses a library call to get to the function, while with Ada it is possible to use Machine_Code and inlining to just "use" the machine instruction. Further, for single-precision SQRT, C must promote the single-precision to double-precision, do the SQRT, and then demote the result. In Ada, the single-precision SQRT machine instruction is all that appears in the code listing. Regards, Steve Deller deller@smsail.com