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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:1881:: with SMTP id 123-v6mr4954054ioy.8.1530908333224; Fri, 06 Jul 2018 13:18:53 -0700 (PDT) X-Received: by 2002:aca:2b06:: with SMTP id i6-v6mr2502014oik.0.1530908332886; Fri, 06 Jul 2018 13:18:52 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!2.eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!85.12.16.69.MISMATCH!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!d7-v6no3925781itj.0!news-out.google.com!z3-v6ni3921iti.0!nntp.google.com!d7-v6no3925774itj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 6 Jul 2018 13:18:52 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=47.185.195.62; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 47.185.195.62 References: <856189aa-fa00-4960-929e-174f352310ad@googlegroups.com> <39fce60c-9f56-42fb-b679-fa08810b00ee@googlegroups.com> <3701bf07-89a5-4cb0-a704-5aebb589ca79@googlegroups.com> <2f5e4ce0-94e8-4b94-9da7-045ec90a9b22@googlegroups.com> <18554067-1382-4b43-a832-2d27aa5117d7@googlegroups.com> <8dc19505-b68a-403c-a164-f1de1864f3f1@googlegroups.com> <559657f8-bbf4-4a70-9449-f85bc98d6c6b@googlegroups.com> <590d4672-4aef-42a5-823c-57ccd291115a@googlegroups.com> <8de6b5ba-25ab-4d46-b80c-1544f43a9b05@googlegroups.com> <670baa25-a987-45a0-991f-ec3aa2878233@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Teaching C/C++ from Ada perspective? From: "Dan'l Miller" Injection-Date: Fri, 06 Jul 2018 20:18:53 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 5535 X-Received-Body-CRC: 3704681929 Xref: reader02.eternal-september.org comp.lang.ada:53705 Date: 2018-07-06T13:18:52-07:00 List-Id: On Friday, July 6, 2018 at 2:43:21 PM UTC-5, Dmitry A. Kazakov wrote: > On 2018-07-06 20:51, Randy Brukardt wrote: > > "Maciej Sobczak" wrote in message > > news:670baa25-a987-45a0-991f-ec3aa2878233@googlegroups.com... > >>> In any case, semantic coupling is many times more important than > >>> compile-time coupling, since it causes actual maintenance problems. > >>> Perhaps > >>> focusing on that would make the differences more apparent??? > >> > >> So let's do focus on that. Is there some short example that you would = like > >> to present to demonstrate this point? > >=20 > > Not off-hand; I shouldn't have wasted the time on this discussion in th= e > > first place. > >=20 > > But I'll say that examples involving empty packages and useless withs d= on't > > really prove anything regardless of the language involved - they're not= very > > realistic. I'd suggest looking at examples of privacy (which Ada is ver= y > > strict about) and comparing to other languages (which I don't know well > > enough to do myself). >=20 > I would add that much depends on optimization. If the compiler looks=20 > into a body in order to perform certain types of optimization then no=20 > matter how excellent Ada's separation of interface and implementation=20 > is, it must recompile clients if the body was changed. >=20 > But Ada will still beat others here, because for quick runs you can turn= =20 > the optimization off being sure that when you turn it on, then due to=20 > the separation the optimized code will still work. Do you use this rule with GNAT or nonGNAT compilers? Given GNAT's GIGI/GIM= PLE/RTL optimizing backend, might GNAT not respect private-package boundari= es when optimizing? > It is a really a plague in C++: the debug version works and the release= =20 > crashes. Never happened in Ada to me. I agree 100%. This happens precisely because of C++'s =E2=80=9Cas-if=E2=80= =9D rule*, permitting the optimizer to interact deleteriously with one or m= ore undefined behaviors (UBs). * The name is a misnomer. A better name would be the =E2=80=98carte-blanch= e=E2=80=99 rule, because the optimizer is handed a blank check to fill out = untrustworthily whenever one or more UBs occur in a program. https://stackoverflow.com/questions/15718262/what-exactly-is-the-as-if-rule It is =E2=80=9Cas if=E2=80=9D** an enemy of C++ snuck into the standards co= mmittee and planted the worst possible contortion of the past momentum of C= ++ culture into the letter of the standard to break vast quantities of real= -world programs when the optimizer is turned on. If they really want this = carte-blanche rule in C++-with-optimization, then then C++ absolutely must = error all UBs when compiled with optimization. But they didn't require suc= h. ** Perhaps that is the real reason that it is called the =E2=80=9Cas if=E2= =80=9D rule instead of the =E2=80=98carte blanche=E2=80=99 rule. This is the reason that multiple C++ shops with which I have been employed = have all picked only one optimization level and performed all development &= debugging & everything at only that one optimization level; builds with th= e optimizer turned off or to any different level were strictly prohibited.