comp.lang.ada
 help / color / mirror / Atom feed
From: dag@control.lth.se (Dag Bruck)
Subject: Re: Ada ad in Embedded Systems Programming stinks
Date: 08 Sep 1994 07:04:46 GMT
Date: 1994-09-08T07:04:46+00:00	[thread overview]
Message-ID: <DAG.94Sep8090447@bellman.control.lth.se> (raw)
In-Reply-To: eachus@spectre.mitre.org's message of 6 Sep 94 09:40:18

>>>>> "RE" == Robert I Eachus <eachus@spectre.mitre.org> 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



  parent reply	other threads:[~1994-09-08  7:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CvFI4J.D5M@world.std.com>
     [not found] ` <34ecqc$b5q@source.asset.com>
     [not found]   ` <34g5v3INN6q2@phage.cshl.org>
1994-09-06 13:46     ` Ada ad in Embedded Systems Programming stinks david.c.willett
     [not found]     ` <EACHUS.94Sep6094018@spectre.mitre.org>
1994-09-08  7:04       ` Dag Bruck [this message]
1994-09-08  9:52         ` Robert I. Eachus
1994-09-08 17:12           ` Dag Bruck
1994-09-08 17:28             ` Robert I. Eachus
1994-09-22  8:51         ` Brendan WALKER
1994-09-07 22:44   ` John Goodsen
1994-09-08  6:32     ` Keith Thompson @pulsar
     [not found] ` <1994Sep1.084046.21595@sei.cmu.edu>
     [not found]   ` <344u9q$di5@gnat.cs.nyu.edu>
     [not found]     ` <347idh$15ss@watnews1.watson.ibm.com>
     [not found]       ` <1994Sep4.092729.21408@lmpsbbs.comm.mot.com>
1994-09-07 22:46         ` John Goodsen
1994-09-08  6:47           ` Keith Thompson @pulsar
1994-09-08  8:52             ` David Emery
1994-09-11  3:41       ` Michael M. Bishop
1994-09-11 12:20         ` Robert Dewar
1994-09-11 13:29           ` Robert Dewar
1994-09-12 14:03             ` Norman H. Cohen
1994-09-11 21:48           ` Erik Naggum
1994-09-11 23:47             ` Robert Dewar
1994-09-12  6:28               ` Dag Bruck
1994-09-12 12:22                 ` David Weller
1994-09-12 20:03               ` Erik Naggum
1994-09-12 19:16             ` Maarten Landzaat
1994-09-13 10:10               ` Richard A. O'Keefe
1994-09-17 12:07                 ` Fred McCall
1994-09-12 20:49         ` Mitch Gart
1994-10-13 10:51 Bob Wells #402
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox