comp.lang.ada
 help / color / mirror / Atom feed
From: ohk@edeber.nta.no (Ole-Hjalmar Kristensen FOU.TD/DELAB)
Subject: Re: Why Ada is not the Commercial Lang of Choice
Date: 1997/06/19
Date: 1997-06-19T00:00:00+00:00	[thread overview]
Message-ID: <umqvi3a3aa3.fsf@edeber.nta.no> (raw)
In-Reply-To: 33A83DA9.67E@lmco.com


Ken Garlington <Kennie.E.Garlington@lmco.com> writes:

> 
> Paul Van Bellinghen writes:
> > 
> > Claim:
> > It is much easier in C, for example, to output a data word to
> > an I/O device that is memory mapped.
> > 
> > Supporting Evidence:
> > 1       One need only define a pointer
> > 2       and assign it the memory mapped address
> > 3       then store the desired data value to the contents of the pointer.
> 
> In Ada, something like:
> 
>    Memory_Mapped_Address : constant := 16#0100040#;
> 
>    Memory_Mapped_Value : Interfaces.C.unsigned; -- just to keep type
> compatibility
>    for Memory_Mapped_Value'Address use Memory_Mapped_Address;
> 
>    Memory_Mapped_Value := 16#00344556#;
> 
> And the neat thing is, Memory_Mapped_Value will always be mapped to the
> area of memory you want! No worries about your pointer being corrupted
> --
> because there isn't a pointer! Who knows, now that the compiler knows
> that the address is fixed, you might even get more efficient code!


You don't need the pointer in C either. Just 

#define Memory_Mapped_Value (*(int *) 0x0100040)

Memory_Mapped_Value = 0x00344556;

has the same effect, except for the scope of Memory_Mapped_Value.


> 
> > 
> > Example:
> >  #define mem_map_addr B0100040
> >  unsigned int *p;
> > 
> >  p = (unsigned int *) mem_map_addr;
> > 
> >  *p = 0x00344556;
> 
> Claim: The Ada does the same thing, in the same number of lines, and it
> does it
> more safety, more clearly, and (gasp) possibly more efficiently!
> 
> --
> LMTAS - The Fighter Enterprise - "Our Brand Means Quality"
> Who uses Ada? See http://www.lmasc.lmco.com/f22
> For job listings, other info: http://www.lmtas.com or
> http://www.lmco.com

Btw., I have been thinking about not being able to assign an explicit
value to the tag of a discriminant union. It will certainly be a
problem, if you intend to store your unions in a file, and read this
file with another Ada program compiled with another compiler.
This would work well in C, because you would typically use an enum
with explicit assignment of values. Now, I am aware that in C, the tag
field is not mandatory, so it's not really a fair comparison, but it
means that you cannot output the union directly. 

Yes, I am aware that it will not be portable from one kind of CPU to
another anyway, and that you can circumvent the problem by converting
to an external data representation, but there are instances where you
want to reduce the overhead as much as possible, for instance when
working in the lower layers of a DBMS.

It seems to me that in Ada, (almost) all problems can be solved,
according to the standard, but in practice, the implementations are
different enough that it does not work in some cases. In C, the
standard does not guarantee that it works, but it will, in all but a
few cases. The actual difference in terms of what is portable isn't
all that great.

That said, from my former experience with Ada, I would personally
rather build a system in Ada than in C/C++ if compilers and
development systems are available at a reasonable price. 
The project I'm working on, originally intended to use Ada (about 7
years ago), but reverted to C++ after seeing the following
difficulties:

1. EVERY potential customer asked why it was written Ada, and not in C++, and
it was clearly seen as a serious drawback.
2. Compilers very very expensive, even compared to C++.
3. Compilers were not available for all the target operating
systems. (it turned out that we now use only Unix anyway, but that's
another story)

I am still convinced that it would have been better to use Ada. We
have had a fair share of bugs which would typically not have occured
if we were using Ada, especially in the homegrown multi-tasking
system. However, from measurements I have been doing, the homegrown
multitasking is also very much faster than using Ada tasks. Of course,
we could avoid using Ada tasks, but then much (not all) of the benefit
of Ada would disappear as well.  And in case you wonder, the task
switching time becomes very significant when you are running 100 -
1000 transactions per second.  But I would rather get it right first,
then optimize.






  reply	other threads:[~1997-06-19  0:00 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-13  0:00 Why Ada is not the Commercial Lang of Choice Paul Van Bellinghen
1997-06-17  0:00 ` Robert Dewar
1997-06-20  0:00   ` nma123
1997-06-24  0:00     ` Adam Beneschan
1997-06-17  0:00 ` Dale Stanbrough
1997-06-17  0:00   ` Robert Munck
1997-06-18  0:00   ` Ken Garlington
1997-06-19  0:00     ` Ole-Hjalmar Kristensen FOU.TD/DELAB [this message]
1997-06-19  0:00       ` Ken Garlington
1997-06-18  0:00 ` Nick Roberts
1997-06-18  0:00   ` Peter Hermann
1997-06-20  0:00     ` Robert Dewar
1997-06-25  0:00     ` Van Snyder
1997-06-26  0:00       ` Robert Dewar
1997-06-30  0:00         ` Ralph Paul
1997-07-02  0:00           ` Joerg Rodemann
1997-07-02  0:00             ` Ralph Paul
1997-07-02  0:00             ` Joerg Rodemann
1997-06-19  0:00 ` Steve Doiel
1997-06-19  0:00   ` Anonymous
1997-07-22  0:00 ` Shmuel (Seymour J.) Metz
  -- strict thread matches above, loose matches on Subject: below --
1997-06-18  0:00 Robert I. Eachus
1997-06-18  0:00 ` Dale Stanbrough
1997-06-19  0:00   ` Robert A Duff
1997-06-21  0:00     ` Paul Van Bellinghen
1997-06-20  0:00       ` Robert Dewar
1997-06-23  0:00         ` John G. Volan
1997-07-03  0:00           ` Shmuel (Seymour J.) Metz
1997-07-03  0:00             ` Robert Dewar
1997-07-06  0:00               ` Yasmiin S. Davis
1997-07-06  0:00                 ` Robert Dewar
1997-07-07  0:00               ` Shmuel (Seymour J.) Metz
1997-07-04  0:00             ` Paul Van Bellinghen
1997-07-13  0:00               ` Ken Mays
1997-07-13  0:00                 ` Robert Munck
1997-07-14  0:00                   ` Ken Mays
1997-06-19  0:00   ` Steve Jones - JON
1997-06-19  0:00     ` Peter Hermann
1997-06-19  0:00     ` Anonymous
1997-07-17  0:00     ` Shmuel (Seymour J.) Metz
1997-06-20  0:00   ` Robert Dewar
1997-06-20  0:00   ` Don Harrison
1997-06-20  0:00     ` Larry Kilgallen
1997-06-20  0:00       ` Nick Leaton
1997-06-23  0:00       ` Don Harrison
1997-06-24  0:00         ` Bertrand Meyer
1997-06-24  0:00           ` Nick Leaton
1997-07-22  0:00           ` Dr. Vladimir Il'ich Fomin
1997-06-20  0:00     ` Donovan Baarda
1997-06-20  0:00     ` Roy Grimm
1997-06-23  0:00     ` Robert Dewar
1997-06-24  0:00       ` Don Harrison
1997-06-24  0:00         ` Robert Dewar
1997-06-23  0:00     ` Joachim Durchholz
1997-06-20  0:00 ` Robert Dewar
1997-06-21  0:00 ` Keith Thompson
1997-06-21  0:00   ` Robert Dewar
1997-06-24  0:00     ` Ken Garlington
1997-06-24  0:00       ` Robert Dewar
1997-06-28  0:00   ` Robert I. Eachus
1997-06-28  0:00     ` Robert Dewar
replies disabled

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