comp.lang.ada
 help / color / mirror / Atom feed
From: Ken & Virginia Garlington <redhawk@flash.net>
Subject: Re: Ada is great for embedded systems (was Ada is almost useless in embedded systems)
Date: 1996/02/17
Date: 1996-02-17T00:00:00+00:00	[thread overview]
Message-ID: <31261528.762D@flash.net> (raw)
In-Reply-To: 311E924E.74CE@escmail.orl.mmc.com

Ted Dennison wrote:
> 
> John McCabe wrote:
> 
> > 1) Strong typing is very good if your coders are learners or possibly
> > not very good, and can be useful to guide you in the direction of bugs
> > at the compilation stage but the enforcement of strong typing can lead
> > to code that is difficult to understand because you end up having
> > numerous type casts and unchecked conversions in order to implement
> > something quite simple. C does not enforce strong typing so you can
> > get away with some very strange code, but if you really want to check
> > where you may find problems, you can use 'lint'.
> 
> For Godlike programmers (such as yourself?), perhaps type checking
> is an inconvienence.... [snip]

I always see a discussion of Ada vs. C typing end up here. Let me suggest
an alternative explanation of Ada vs. C typing, which is hinted at in Mr.
McCabe's comment.

If you don't want to use strong typing in Ada, _don't_. You can write Ada
code that has basically the same level of type checking as in C, and it
will run. There's very little in Ada that forces type casts and unchecked
conversions, particularly for simple programs.

Here's the distinction. If I _do_ want to use strong typing in Ada,
and I think it's important for the users of my code to pay attention to that
typing since it's necessary to understanding how my code works, I can do it.
In "C", I can't force users of my code to run lint, purify, and all these
neat C add-ons I see advertised in the magazines for several hundred
dollars a pop. I can put in comments, and cross my fingers, and that's about it.
I know that my code may be used by new hires, or super-programmers coming off
vacation in the Bahamas, so I may want to be precise in how I define my solution.
(See "defensive programming" in the software engineering literature.)

Ada is written in terms of the writer of code defining what should be done
with it, rather than the user. This has its good and bad points, but the Ada
approach is pretty common to manufactured items in general (e.g., the warranty gets
voided if you use the product in a way not defined by the manufacturer). If we want to 
think of software more as a set of manufactured components, and less as an art form, 
then the Ada way seems to be a good way to start. Of course, lots of people like art 
better than manufacturing, so it's not going to please everyone.

> > 2) In the system I am currently developing I have discovered a need
> > use bitwise logical functions on a register which contains 16 bits,
> > all of which are accessed at one time, and all of which have identical

I do this all the time in my Ada 83 embedded systems, so I don't know what the
problem is here. Early Ada 83 implementations were somewhat inefficient with bit
ops, but current products do a reasonable job here.

> > 3) When I'm designing/implementing a system, I like to follow the
> > order of command lists provided in requirement specification when
> > defining enumerated types of these command. I tend to have very little

> 
> So what? As long as they are all there, who cares what order they are
> listed in? I don't see how this cripples Ada to the point where it is
> useless. C doesn't even HAVE enumerated types! You'd have do use
> a series of constants, which you can do in Ada as well!!

I think the issue is: If in the spec, a discrete is listed as Open/Closed, then
it would be nice for the type to read (Open, Closed). However, if Open=1 and
Closed=0, then you have to reverse the order in the type. I've never noticed
this in our embedded systems, since our engineers list these in ascending order.

It is a good point that Ada enumerated values are really useful in embedded systems,
particularly those with a lot of inverted discretes (e.g. On=0, Off=1). It is
much less error-prone than using constants, where the old cut-and-paste error

  On: constant := 0;
  Off: constant := 0;

always seemed to be hanging around.

> > 4) Pascal provides variant records, C provides unions and Ada provides
> > variant records. What differences are there between these? Obviously I
> > am aware that none of these languages guarantee that the variants are
> > front of the record type. How can you map this onto e.g. a 1553 bus
> > command buffer where the command structure is NOT defined to fit into
> > the Ada variant record type structure? This has been implemented in my

Actually, we've not had any problems using Ada with our 1553 interfaces. It
may be that our mappings are just a little less perverse...

> > 5) Finally chapter 13. What is the point of having a program to come
> > up with a portable, general purpose, 'standard for use in DoD
> ...
> > reasoning of this and I think it is stupid. At work we have 3 Ada
> > compilers for MIL-STD-1750A targets and we have been surprised at the
> > amount of work that is involved in getting a single piece of code to
> > compile under all three. Previously I used Motorola's implementation
> > of GCC for a DSP56001 target, and the HP UNIX ANSI standard compiler
> > on a single piece of code, without modification, and they both
> > compiled the code perfectly. This proves to me that C is a far more
> > portable language than Ada.

Have you tried to port C code between three different 1750 compilers? For some
reason (probably the small user base), comparisons of 1750 target compiler
capabilities vs. host compilers (e.g. HP) always come off bad. This
is true for Ada, and I suspect it's true for C as well. (Did you have any trouble
getting the HP to fix in the same space as the 1750? :)

However, we have ported large chunks of code between DEC Ada, Telesoft Ada/1750,
and Tartan Ada/1750 with no trouble. So, it may be a consequence of the way you
had to write your Ada code, or you just picked some bad compilers, or you need the
extra power of Ada 95 to make your code portable. I don't know.




  parent reply	other threads:[~1996-02-17  0:00 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <823906039.22113@assen.demon.co.uk>
     [not found] ` <4fgrq3$mc4@qualcomm.com>
     [not found]   ` <dewar.823962356@schonberg>
1996-02-17  0:00     ` Ada is almost useless in embedded systems Tore Joergensen
1996-02-17  0:00       ` Robert Dewar
1996-02-19  0:00       ` Keith Thompson
1996-02-19  0:00         ` John McCabe
1996-02-21  0:00           ` Richard A. O'Keefe
1996-02-21  0:00             ` Norman H. Cohen
1996-02-19  0:00 ` AdaWorks
1996-02-21  0:00   ` Ken Garlington
1996-02-23  0:00     ` AdaWorks
1996-02-19  0:00 ` R.A.L Williams
1996-02-21  0:00   ` Richard A. O'Keefe
     [not found] ` <824056183.18993@assen.demon.co.uk>
     [not found]   ` <311E924E.74CE@escmail.orl.mmc.com>
1996-02-17  0:00     ` Ken & Virginia Garlington [this message]
     [not found]   ` <4fnqpm$3nh@news.sanders.lockheed.com>
1996-02-19  0:00     ` AdaWorks
1996-02-21  0:00       ` Hugh Dunne
1996-02-21  0:00       ` Ken Garlington
     [not found]   ` <4fnp37$nj1@theopolis.orl.mmc.com>
1996-02-22  0:00     ` Alan Brain
1996-02-19  0:00 ` Jon S Anthony
1996-02-26  0:00 ` R.A.L Williams
     [not found]   ` <4h3q56$1vk@goanna.cs.rmit.EDU.AU>
     [not found]     ` <dewar.825635955@schonberg>
     [not found]       ` <826571250.140@assen.demon.co.uk>
     [not found]         ` <dewar.826634800@schonberg>
1996-03-21  0:00           ` John McCabe
1996-03-23  0:00             ` Side-effect arithmetic again [was: Ada ... in embedded systems] John G. Volan
1996-03-23  0:00               ` Robert Dewar
1996-03-25  0:00                 ` Tucker Taft
1996-03-25  0:00                   ` Robert A Duff
1996-03-25  0:00                   ` Norman H. Cohen
1996-03-26  0:00               ` John G. Volan
1996-03-26  0:00                 ` Robert A Duff
1996-03-26  0:00                   ` Tore Joergensen
1996-03-27  0:00                     ` John G. Volan
1996-03-27  0:00                     ` John G. Volan
1996-03-28  0:00                       ` Tucker Taft
1996-03-28  0:00                         ` Robert Dewar
1996-03-29  0:00                           ` Tucker Taft
1996-03-29  0:00                             ` Tucker Taft
1996-03-27  0:00                     ` John G. Volan
1996-03-29  0:00                       ` Robert A Duff
1996-03-30  0:00                         ` John G. Volan
1996-03-30  0:00                         ` John G. Volan
1996-03-31  0:00                           ` AdaWorks
1996-04-01  0:00                           ` Robert A Duff
1996-03-26  0:00                 ` Robert Dewar
1996-03-29  0:00                   ` Robert I. Eachus
     [not found] ` <emery-0902962215150001@line316.nwm.mindlink.net>
     [not found]   ` <DMoA85.52I@eskimo.com>
     [not found]   ` <823965654.4500@assen.demon.co.uk>
     [not found]     ` <824165619.14894@assen.demon.co.uk>
     [not found]       ` <JSA.96Feb13133713@organon.com>
     [not found]         ` <824332550.2485@assen.demon.co.uk>
1996-02-17  0:00           ` Ada is almost useless in embedded systems Ken & Virginia Garlington
1996-02-17  0:00             ` Robert Dewar
1996-02-18  0:00               ` John McCabe
1996-02-18  0:00                 ` Robert Dewar
1996-02-19  0:00                   ` John McCabe
     [not found]         ` <824259217.26321@assen.demon.co.uk>
1996-02-17  0:00           ` Robert Dewar
1996-02-18  0:00             ` John McCabe
1996-02-18  0:00               ` Robert Dewar
1996-02-19  0:00                 ` John McCabe
1996-02-20  0:00                   ` Robert Dewar
1996-02-21  0:00                   ` Fergus Henderson
     [not found]       ` <4fs7ml$cf1@rational.rational.com>
1996-02-26  0:00         ` Ada 83 " Alan Brain
     [not found] ` <RALW.96Feb28100925@vulcan.gmrc.gecm.com>
1996-03-15  0:00   ` Ada is almost useless " Robert I. Eachus
     [not found]     ` <dirk.827148504@demokrit>
1996-03-18  0:00       ` David Weller
1996-03-18  0:00     ` Alan Brain
     [not found]       ` <4ik5bm$ogg@dayuc.dayton.saic.com>
1996-03-18  0:00         ` Side-effect arithmetic again [was: Ada ... in embedded systems] Robert Dewar
1996-03-19  0:00           ` Norman H. Cohen
1996-03-19  0:00           ` Jay Martin
1996-03-21  0:00             ` Robert I. Eachus
     [not found]   ` <dewar.825775334@schonberg>
     [not found]     ` <RALW.96Mar8113005@vulcan.gecm.com>
     [not found]       ` <4hv2fb$6ra@cville-srv.wam.umd.edu>
     [not found]         ` <4xybp895y6.fsf@leibniz.enst-bretagne.fr>
     [not found]           ` <3144CC40.33A0@escmail.orl.mmc.com>
     [not found]             ` <dewar.826604375@schonberg>
     [not found]               ` <3145FF2C.6139@escmail.orl.mmc.com>
     [not found]                 ` <dewar.826829407@schonberg>
     [not found]                   ` <31499D21.1DA6@escmail.orl.mmc.com>
1996-03-15  0:00                     ` Bug or Limitation? (was: Ada is almost useless in embedded systems) Robert Dewar
1996-03-16  0:00                       ` Ted Dennison
1996-03-20  0:00                         ` Side-effect arithmetic again [was: Ada ... in embedded systems] Robert I. Eachus
1996-03-20  0:00                           ` John G. Volan
1996-03-22  0:00                             ` Alan Brain
1996-03-20  0:00                           ` Robert A Duff
1996-03-21  0:00                             ` Peter Hermann
1996-03-21  0:00                               ` Robert Dewar
1996-03-25  0:00                                 ` Robert I. Eachus
1996-03-28  0:00                               ` Mats Weber
1996-03-29  0:00                                 ` John G. Volan
1996-03-21  0:00                           ` Geert Bosch
1996-03-26  0:00                           ` Mats Weber
1996-03-16  0:00 ` Ada is almost useless in embedded systems Kevin Dalley
replies disabled

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