[comp.lang.ada] C++ & Real-time

larry@JPL-VLSI.ARPA (03/20/87)

--The following was sent to me personally so I've left off the senders' name.

>   I basically agree with your comments abour complexity.  I would put it
>   between PL1 ... and some of the larger Pascal dialects. C++ has
>   nothing to do with Ada.  It was an experiment by Bjorn to put object-
>   oriented features into the language.  It went a lot further than planned.
>
>   Real time: No the designers are not ignorant.  They are not optional
>   and if they are not available, its not Ada.  Portions of Ada are
>   good in a general purpose sense.  Writing an Ada program like COBOL
>   would be interesting since COBOL is basically a formatting language.
>   (I can see it now, some package of COBOL defs.....).  There are
>   better ways to do this kind of job (over COBOL OR Ada).  No I think 
>   it is mostly a real-time language, and your argument here is weak.

C++:      I realize Stroustrup began it as an experiment, but I get the
impression AT&T is encouraging it for reasons of their own.  I find it
interesting that things ordinary C hackers scream about in Ada (strong
typing, various black-boxing features) have been added by the el primo C
hackers at AT&T. 

And some of its features do seem similar to Ada.  In classes (packages) all
data is private unless declared public, for instance.  Except that it's done
"backwards" from Ada's PRIVATE this declaration seems identical.  Operators
and functions can be overloaded (assignment cannot).  Classes can be
generic.  Other features, as Richard Welty points out, are closer to Simula.

Real-time:        I obviously need to clarify my comments.  Representation
specs are explicitly defined in the standard as optional.  It is through
them that bit-twiddling and interrupts can be done in Ada; without them one
cannot do real-time programming.  The pragma INLINE is only a recommendation
to the compiler.  It is also important for real-time programming (though
less so than rep specs) because you can eliminate subprogram-call overhead
for actions that have to been done very fast. 

Perhaps Ada's biggest deficiency (for r-t programming) is its handling of
time, which is at the very core of real-time programming.  There is no Ada
facility to schedule an action at a specific time or within a min or max
time, for instance.  (The DELAY statement only guarantees a minimum delay.)

These are the reasons why I say Ada is not designed (for whatever reasons)
to be a real-time language.  To continue to limit it only to that fairly
small problem domain by falsely labeling it does the Ada community a
disservice.

CoBOL-like Ada:      I agree that we don't want to slavishly duplicate the
one feature of CoBOL where it really shines, data formatting.  As good as
that is, there're probably several ways to improve on it.  Ada can be
especially useful here because it can be extended into any number of
special-purpose languages.  Yet, since this is done WITHIN THE STANDARD,
their users only have to learn the extensions--which are abstractions with
which they are already familiar.  (Thus my example of orders triggering the
creation of shippers, back-orders, and invoices.)

bs@alice.UUCP (03/20/87)

larry@JPL-VLSI.ARPA.UUCP (larry @ The ARPA Internet) writes

> C++:      I realize Stroustrup began it as an experiment, but I get the
> impression AT&T is encouraging it for reasons of their own. 

Correct. My (naturally biased) impression is that AT&T (that is, AT&T
management) is encouraging the use of C++ because they think that their
programmers like it (many do) and because they think using C++ improves
productivity and quality significantly (it often does).

> I find it interesting that things ordinary C hackers scream about in Ada
> (strong typing, various black-boxing features) have been added by the el
> primo C hackers at AT&T.

Yes. There is an important point, however, C++'s type structure is very
flexible (so that it rarely gets in your way), and allows the usual C
tricks when needed (e.g. direct access to memory for bit-fiddling,
interupt handling, etc, and functions with partially checked argument
lists, such as printf()). This flexibility difuses some of the fear that
``ordinary C hackers'' have when you say ``strong typing''; they fear you
want to force them to go back to programming in vanilla Pascal.

> And some of its features do seem similar to Ada.  In classes (packages) all
> data is private unless declared public, for instance.

A class is a type not a package.

Anyway any two languages defined in the same world at approximately the same
time for approximately the same range of applications will have similarities.
It is probably fair to say that C++ resembles Ada in the same way that C
resembles Pascal.

> Operators and functions can be overloaded (assignment cannot).

Assignment can be overloaded in C++.

> Classes can be generic.

We may have a problem with terminology here. As I understand the term
``generic'' (parameterized with a type), C++ classes cannot be generic.
You can use derivation (sub-classes), pointers to functions, and/or macros
to achieve polymorphism, but there are no direct support for Ada-like
generics in C++ (this is not a critisism of Ada).

> Other features, as Richard Welty points out, are closer to Simula.

Exactly.