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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:ba09:: with SMTP id p9-v6mr4195659itf.48.1530478356623; Sun, 01 Jul 2018 13:52:36 -0700 (PDT) X-Received: by 2002:a9d:630a:: with SMTP id q10-v6mr933678otk.5.1530478356412; Sun, 01 Jul 2018 13:52:36 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!u78-v6no2520114itb.0!news-out.google.com!p13-v6ni3805itf.0!nntp.google.com!d7-v6no2547514itj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 1 Jul 2018 13:52:36 -0700 (PDT) In-Reply-To: <856189aa-fa00-4960-929e-174f352310ad@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=213.108.152.51; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S NNTP-Posting-Host: 213.108.152.51 References: <856189aa-fa00-4960-929e-174f352310ad@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Teaching C/C++ from Ada perspective? From: Maciej Sobczak Injection-Date: Sun, 01 Jul 2018 20:52:36 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:53494 Date: 2018-07-01T13:52:36-07:00 List-Id: > After having spent some years with Ada, I'm relecutant to "throw away" my= good programming habits from Ada and embrace C/C++. There is absolutely no reason to throw away your good habits. On the contra= ry, your good habits (no matter where you got them from, Ada or elsewhere) = will be very useful when teaching C++ (or whatever else). > I would like to know if there exist(s) good book(s) at introductory level= for C/C++ that may go in the spirit of Ada No and there should not be any, just as there are no introductory books tea= ching Ada in the spirit of C++. This would be pointless, as the spirits of = different languages are different and forcing one language into the spirit = of another one is counterproductive. Having said that, you might think that the two answers above are contradict= ory. They are not, because they refer to distinct aspects. Ada is strong in directing the user towards a good program structure. Pick = this and try to show your students how to design the program in C++ using t= he tools that it has - namespaces and classes. The notion of packages in Ad= a 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 the= physical structure of translation units in C++ can be used to enhance enca= psulation. Show them how to use templates. Use the standard library wheneve= r you can. Stay away from raw pointers as long as you can (which might as w= ell be forever). Now, I take the risk of being controversial here, but I have enough C++ exp= erience to stand by my words: don't bother implementing your own broken ver= sion of integer ranges in C++, no matter whether with macros or with templa= tes. Just don't. If you try to do this, you will teach your students someth= ing that they will not be able to reuse or translate in the real world, in = the real existing code. You will be blamed afterwards for the bad teaching = and you will have nothing to defend yourself. Just don't. It is true that s= ome attempts have been made in this direction, but none got any recognizabl= e acceptance. C++ is not the language for doing ranges and I'm not sure whe= ther this is entirely bad - don't confuse them with range-checked arrays, w= hich 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 inco= mpatible types for everything, as some Ada books insist on. Classes as sepa= rate types are good for medium to big design concepts, but not for microman= aging integers. Don't bother with reimplementing Ada in C++ at this level a= nd you will be successful in your teaching. > so that I won't feel wasting my time and energy teaching C/C++? It works the other way round. If you don't accept this position, your time = and energy will be wasted, because you will not be able to pass your good h= abits to C++ students. Somebody else will pass their bad habits instead. Su= rprise. > Also I will start the above course with Algorithms in which I have little= knowledge. Any suggestions for good books on this topic? There are plenty of algo books that base their presentation on C++. Another= surprise. --=20 Maciej Sobczak * http://www.inspirel.com