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,fc52c633190162e0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!newshub.sdsu.edu!newscon04.news.prodigy.net!prodigy.net!newsdst01.news.prodigy.net!prodigy.com!postmaster.news.prodigy.com!newssvr23.news.prodigy.net.POSTED!4988f22a!not-for-mail From: Newsgroups: comp.lang.ada References: <1172144043.746296.44680@m58g2000cwm.googlegroups.com> <1172161751.573558.24140@h3g2000cwc.googlegroups.com> <546qkhF1tr7dtU1@mid.individual.net> <5ZULh.48$YL5.40@newssvr29.news.prodigy.net> <1175215906.645110.217810@e65g2000hsc.googlegroups.com> <1175230700.925143.28490@n59g2000hsh.googlegroups.com> <6XbPh.4025$u03.802@newssvr21.news.prodigy.net> <1175491660.511530.58430@y80g2000hsf.googlegroups.com> Subject: Re: why learn C? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Message-ID: NNTP-Posting-Host: 70.134.100.216 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr23.news.prodigy.net 1175515166 ST000 70.134.100.216 (Mon, 02 Apr 2007 07:59:26 EDT) NNTP-Posting-Date: Mon, 02 Apr 2007 07:59:26 EDT Organization: AT&T http://yahoo.sbc.com X-UserInfo1: O@Y[R^[GZRRER_H]]RKB_UDAZZ\DPCPDLXUNNH\KMAVNDQUBLNTC@AWZWDXZXQ[K\FFSKCVM@F_N_DOBWVWG__LG@VVOIPLIGX\\BU_B@\P\PFX\B[APHTWAHDCKJF^NHD[YJAZMCY_CWG[SX\Y]^KC\HSZRWSWKGAY_PC[BQ[BXAS\F\\@DMTLFZFUE@\VL Date: Mon, 2 Apr 2007 05:00:15 -0800 Xref: g2news1.google.com comp.lang.ada:14735 Date: 2007-04-02T05:00:15-08:00 List-Id: "kevin cline" wrote in message news:1175491660.511530.58430@y80g2000hsf.googlegroups.com... > > For me, the short reason is that Ada generics are not as powerful as C+ > + templates. The power of C++ templates has enabled me to write > compact, efficient type-safe application code at a very high level in > a way which is not possible in Ada. > I take your central point to be something related to the number of instantiations required in Ada to accomplish a roughly equivalent result in C++. I will grant you that Ada does require more code for each instantiation. This tends to increase, not decrease, the dependability since each instantiation is checked at compile-time. Further, an example you provide, shown below: With C++ templates it was a relatively simple matter to define an algebra on those functions so that one could say things like: Time end = integrate_until(f1 * phase_shift(f2,start) / f3 + f4, q); even though f1, f2, f3, and f4 were possibly of different types. illustrates the problem quite nicely. In fact, your acknowledgement of the "different types" is quite telling. Further, the ad hoc pointer is potentially problematic. A similar construct in Ada, using an access to a function, requires the function to be type conformant and parameter conformant prior to being incorporated into the construct. That is, there is more compiler checking before this construct is even allowed to be compiled. Type-safety is not a very strong argument for C++. Granted, there has been improvement in the latest version of the language. Some (but not all) of the unruly pointer behavior is gone. However, by reference constructs are still a potential source of error. Friends are still problematic. And the disjoint between .h and .cpp files can create entertaining moments in the life of the programmer. You use typdef quite a bit. The examples you give are reasonable. However, typedef does not provide the level of type safety one would expect in a corresponding Ada program. There is a structural equivalence that poses some danger. The reality is that C++ is not really as type-safe as Ada. Consider the automatic promotion of values from an integer to a float. While this might seem trivial on the surface, it is not a good example of type-safety -- certainly not an example of strict typing. I take your point about not using simple arrays. The responsible C++ programmer will not use that feature. Ooops! Sorry. I still see a lot of C++ code written that way, and even using pointer computation. It is just too easy to do that instead of using those pesky libraries. And the wonderful assortment of type-casting one finds in C++ brings even more joy to the development process. Particularly amusing is casting away const. One could go on, but it is 5 AM in the morning, and I need to get ready for work. The verbosity in Ada is no accident. The programs are intended to be more readable than writeable. They are intended to be more reliable and to be more checkable at compile-time. Those are fundamental goals. They are, for the most part, achieved. There is a good reason why Ada does not have some of the wonderful little shortcuts you find so charming in C++: those shortcuts and defaults are simply not suitable for producing dependable code. In my most recent meeting with a bunch of C++ developers, there was general agreement that one must use C++ with great care to avoid creating horrible programs. Everyone who uses C++ (except you, it seems) realizes that the language is fraught with traps for the unwary programmer -- and even the wary programmer. I would expect one would want a language where the focus was on using the language to solve application problems, not to solve language problems. This is where Ada and C++ part company. When using Ada, I am able to focus on the application problem rather than worrying about the pitfalls inherent in the language. Richard Riehle