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:a24:69c2:: with SMTP id e185-v6mr916275itc.55.1530480920410; Sun, 01 Jul 2018 14:35:20 -0700 (PDT) X-Received: by 2002:aca:8d2:: with SMTP id 201-v6mr2376489oii.0.1530480920211; Sun, 01 Jul 2018 14:35:20 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!news.redatomik.org!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!85.12.16.70.MISMATCH!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!d7-v6no2573119itj.0!news-out.google.com!p13-v6ni3805itf.0!nntp.google.com!d7-v6no2573115itj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 1 Jul 2018 14:35:19 -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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2718c8d4-5f35-4fd8-a1aa-1e60069a7a5d@googlegroups.com> Subject: Re: Teaching C/C++ from Ada perspective? From: "Dan'l Miller" Injection-Date: Sun, 01 Jul 2018 21:35:20 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 5209 X-Received-Body-CRC: 628302475 Xref: reader02.eternal-september.org comp.lang.ada:53495 Date: 2018-07-01T14:35:19-07:00 List-Id: On Sunday, July 1, 2018 at 3:52:37 PM UTC-5, Maciej Sobczak wrote: > > After having spent some years with Ada, I'm relecutant to "throw away" = my good programming habits from Ada and embrace C/C++. >=20 > There is absolutely no reason to throw away your good habits. On the cont= rary, your good habits (no matter where you got them from, Ada or elsewhere= ) will be very useful when teaching C++ (or whatever else). >=20 > > I would like to know if there exist(s) good book(s) at introductory lev= el for C/C++ that may go in the spirit of Ada >=20 > No and there should not be any, just as there are no introductory books t= eaching Ada in the spirit of C++. This would be pointless, as the spirits o= f different languages are different and forcing one language into the spiri= t of another one is counterproductive. >=20 > Having said that, you might think that the two answers above are contradi= ctory. They are not, because they refer to distinct aspects. >=20 > Ada is strong in directing the user towards a good program structure. Pic= k this and try to show your students how to design the program in C++ using= the tools that it has - namespaces and classes. The notion of packages in = Ada do not map 1:1 into namespaces and classes in C++, but the big picture = of encapsulation and program decomposition translates well. Show them how t= he physical structure of translation units in C++ can be used to enhance en= capsulation. Show them how to use templates. Use the standard library whene= ver you can. Stay away from raw pointers as long as you can (which might as= well be forever). >=20 > Now, I take the risk of being controversial here, but I have enough C++ e= xperience to stand by my words: don't bother implementing your own broken v= ersion of integer ranges in C++, no matter whether with macros or with temp= lates. Just don't. If you try to do this, you will teach your students some= thing that they will not be able to reuse or translate in the real world, i= n the real existing code. You will be blamed afterwards for the bad teachin= g and you will have nothing to defend yourself. Just don't. It is true that= some attempts have been made in this direction, but none got any recogniza= ble acceptance. C++ is not the language for doing ranges and I'm not sure w= hether this is entirely bad - don't confuse them with range-checked arrays,= which are available in the standard library and are (and should be) used. = In the same spirit, don't get obsessed too much on defining gazillion of in= compatible types for everything, as some Ada books insist on. Classes as se= parate types are good for medium to big design concepts, but not for microm= anaging integers. Don't bother with reimplementing Ada in C++ at this level= and you will be successful in your teaching. >=20 > > so that I won't feel wasting my time and energy teaching C/C++? >=20 > It works the other way round. If you don't accept this position, your tim= e and energy will be wasted, because you will not be able to pass your good= habits to C++ students. Somebody else will pass their bad habits instead. = Surprise. Oh, so the take-away is: bad C++ instructors don't teach classes and names= paces and C++ standard library's containers? =E2=80=A2=E2=80=A2Make sure t= hat you use classes & namespaces & C++ standard library's containers=E2=80= =A2=E2=80=A2 is the level of deep-wisdom contribution that an insightful Ad= a perspective brings to C++? Wow, bad C++ instructors must be really reall= y bad if they skip or botch those 3 topics. Who knew? I strongly believe that thinking-in-Ada has so vastly much more to contribu= te to C++-based program design than merely =E2=80=9CMake sure that you use = classes & namespaces & C++ standard library's containers=E2=80=9D.