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: a07f3367d7,4215feeab2a8154a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!de-l.enfer-du-nord.net!gegeweb.org!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: C++0x and Threads - a poor relation to Ada's tasking model? Date: Wed, 12 Aug 2009 20:28:27 -0500 Organization: Jacob Sparre Andersen Message-ID: References: <7q2385104kihs87d79p8kfphuoki6r01vq@4ax.com> <7961a91c-a5af-40e2-bbc0-6bf69a98176d@z31g2000yqd.googlegroups.com> <362f621e-a01c-4772-ba02-4e18e9962188@j19g2000vbp.googlegroups.com> <128d63da-361f-4e33-be5e-e06bdc71e39f@r34g2000vba.googlegroups.com> <6d23274b-d649-4a83-a6f1-6d1e9c4c3998@d34g2000vbm.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1250126974 18448 69.95.181.76 (13 Aug 2009 01:29:34 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 13 Aug 2009 01:29:34 +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.5579 Xref: g2news2.google.com comp.lang.ada:7709 Date: 2009-08-12T20:28:27-05:00 List-Id: "REH" wrote in message news:6d23274b-d649-4a83-a6f1-6d1e9c4c3998@d34g2000vbm.googlegroups.com... On Aug 12, 4:41 pm, Robert A Duff wrote: ... >> C++ and Ada both share this philosophy. It's called >> "avoid distributed overhead". > >The reason I said "potentially" is you may or maybe pay the cost in >Ada, depending on the implementation. There are implementations where >you will always pay a speed penalty for exceptions (e.g., in setting >up the frame), and there are ones where you only pay if an exception >is raised (e.g., a table-based implementation). A C++ compiler will >not make me "pay" the cost of exceptions if I never make use of them. >What I mean by that is, if I don't have a try block, there will never >be any setup code to catch or propagate exceptions. In Ada, you may or >may not. It seems to me that you are says Ada and C++ are exactly the same here. The cost for exception handling in Ada only exists if you have an exception handler. I've never seen an Ada implementation that has any overhead for a frame that doesn't contain a handler - it would be a horrible performance drag. That's essentially equivalent to the C++ situation, as a "try block" is roughly equivalent to an Ada block with an exception handler. (Ada just allows handlers in more places.) >Similarly with range-checking. If I index an array in Ada, it may or >may not range check the index (a smart compiler can remove the check >if it can prove it cannot be out-of-range). C++ will not range check >the index. I have to do it explicitly (which is why I used that word), >or if I am using vectors, call the at member explicitly. Range checking is very cheap (generally only a couple of instructions); you can only detect the overhead in benchmarks. The odds that it would matter to a program is minimal (and the program is a lot safer for its enclusion). Overhead from exceptions and potentially finalizations are several orders of magnitude larger, and matter a lot more. Premature optimization (which includes worrying about overhead without determining that it is significant) is the root of much evil. Randy. REH