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,bb7cc916bd63ab43 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!newsfeed.straub-nv.de!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Performance of element access in Vector Date: Tue, 20 Jan 2009 17:01:28 -0600 Organization: Jacob Sparre Andersen Message-ID: References: <0a8baaf0-19f7-40c0-a041-884e93fa7020@w39g2000prb.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1232492516 27419 69.95.181.76 (20 Jan 2009 23:01:56 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 20 Jan 2009 23:01:56 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: g2news1.google.com comp.lang.ada:3459 Date: 2009-01-20T17:01:28-06:00 List-Id: > "Maciej Sobczak" wrote: >> What happens in C++ when the element whose reference you are using is >> deleted? > >Formally speaking - undefined behavior. >The difference is, however, that it is possible to use vectors in C++ >without going into undefined behavior, whereas it seems to be impossible to >use Vectors in Ada without being slow. Maybe it is possible to avoid undefined behavior, but only if you (the programmer) never makes mistakes. I don't think such a programmer exists. The containers in Ada are designed to be safe; that necessarily requires giving up a bit of performance. We didn't go all the way to perfectly safe in order to keep some modicum of performance. But, honestly, if the performance of some data structure in your program is critical enough to make it worth timing, then it should not be written using a predefined container -- anybodies predefined containers. But for the vast majority of programs (probably over 90% of uses), the performance of a container (so long as it is reasonable) is not relevant. >I think that given two correct programs a typical customer will pick >the faster one. In the absense of using SPARK or somthing like it, there are no correct programs. There are only more or less buggy ones, and ones that are more tolerant of bugs. (Testing proves nothing whatsoever about correctness; it can only prove that a program appears to work for a particular set of input. And I say "appears to work" because getting the right answer doesn't prove anything about the absense of bugs, either, it only proves that there aren't any bugs that change the answer. We Ada programmers do spend some time fixing bugs that don't actually affect the answer (such as unused initialization values that are out of range).) So the real question is what amount of confidence that you have in the correctness of the program. Sadly, end users cannot tell the quality of the development process used on a program, so they end up thinking all programs are barely functioning garbage and then pick the one that is faster by 0.01 sec (which is not noticable to a human) or, more likely, pick the one with the "cooler" graphics (despite the fact that the program itself is barely usable and not at all understandable). Randy.