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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b0123581076a0cf3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-08 12:53:58 PST Path: nntp.gmd.de!xlink.net!slsv6bt!slbh01.bln.sel.alcatel.de!rcvie!Austria.EU.net!EU.net!sunic!news.lth.se!nic.lth.se!dag From: dag@control.lth.se (Dag Bruck) Newsgroups: comp.lang.ada Subject: Re: Ada ad in Embedded Systems Programming stinks Date: 08 Sep 1994 07:04:46 GMT Organization: Department of Automatic Control, Lund, Sweden Message-ID: References: <34ecqc$b5q@source.asset.com> <34g5v3INN6q2@phage.cshl.org> NNTP-Posting-Host: control.lth.se In-reply-to: eachus@spectre.mitre.org's message of 6 Sep 94 09:40:18 Date: 1994-09-08T07:04:46+00:00 List-Id: >>>>> "RE" == Robert I Eachus writes: RE> Most Ada avocates, myself included, read, understand, and even use RE> C where appropriate. We do not treat C programmers as heretics, RE> we regard those who speak only C illiterate. I agree completely that experience with multiple languages is a great help in attacking programming problems, not the least because an idiom commonly used in another language may perfectly describe something that is unusual in the language you normally use. For example, in natural languages the Swedish word "lagom" describes something between two extremes that is satisfactory to all parties; I haven't yet found an English word with the same connotations (so pardon me for the imprecise description). I digress; I would instead point out that there are significant differences between C and C++, and several postings on comp.lang.ada do C++ unjustice by taking problems in C and transfering them to C++. First, there are several areas where checking in C++ is tighter than in C, for example: - function must be declared before it is called - function arguments must declared (not in K&R C) - no implicit conversion from void* to any other pointer - no implicit conversion from integer to enumeration - jumps may not by-pass variable initialization Second, C++ encourages a programming style that leads to better programs: - constructors/destructors provide guaranteed initialization and finalization - objects can be declared between statements, which gives a style where variables are not declared until they can be initialized (=> no uninitialized variables) - references, in particular as function parameters, reduces the use of pointers (references must be initialized and refer to an object) - classes give better program structure (cf. Ada packages) - better encapsulation of data (private parts of objects) It worth pointing out that the items above are "traditional" in the sense that they have nothing to do with object-oriented programming; C++ is more than "OO-C." There are of course newer features, such as, - support for OOP, inheritance and virtual functions - generics - overloading - exception handling RE> Passing an object instead of a pointer to it (the earlier RE> example) is a difference between Ada and C. As described above, this is a case where C++ should appeal more than C to the Ada programmer. Finally a comment on the Ada/C/C++ "language wars:" I think the issue is to use C++ instead of C, not to use C++ instead of Ada, at least for the great majority of programmers. -- Dag Bruck, C++ fan