No call for it

38 views
Skip to first unread message

Carroll-Tech

unread,
Feb 7, 2004, 3:50:28 AM2/7/04
to comp.l...@ada-france.org

----- Original Message -----
> Message: 10
> Date: Fri, 06 Feb 2004 16:23:38 GMT
> From: Les Cargill <lcar...@worldnet.att.net>
> Subject: Re: Announcing new scripting/prototyping language
> To: comp.l...@ada-france.org
> Message-ID: <4023C090...@worldnet.att.net>
> Content-Type: text/plain; charset=us-ascii
>
[snip]
> I've seen some fair sized 'C' and C++ projects. They are readable -
> to 'C'/C++ programmers.
>
> I'd have loved to have used Ada, but there never was much call for
> it.

I've been reading posts to this newsgroup for some time now, as well as
reading other information and I don't get the "never was much call for it"
ideal about Ada.
I'm not saying that anyone is wrong or right for saying or feeling that
there "never was much call for it"; maybe there wasn't. I'm leaning more
toward saying "it's a conscious choice".

I tell the students that I tutor that learning some Pascal or Ada would help
them and they get scared. I mention doing a project in Ada and everyone
looks at me like I'm out to punish myself. To me it isn't any easier to use
C/C++, Java, Perl, Lisp or Prolog than it is to use Ada. How is it that Ada
has this "super powerful", "super difficult", "there's not much call for it
because it's too advanced and powerful" air about it when it's just another
language? It's like saying that the machine code spit out of an Ada
compiler has some mystical, magical properties that makes the Ada language
more difficult to use.

To me, with Ada0Y coming out, the "not much call for it" attitude is the
cliché to dismiss. Or at least one of the things to overcome.

Just my opinion as a reader of comp.lang.ada.

Ludovic Brenta

unread,
Feb 7, 2004, 8:00:35 AM2/7/04
to
"Carroll-Tech" <and...@carroll-tech.net> writes:

> I tell the students that I tutor that learning some Pascal or Ada
> would help them and they get scared. I mention doing a project in
> Ada and everyone looks at me like I'm out to punish myself. To me
> it isn't any easier to use C/C++, Java, Perl, Lisp or Prolog than it
> is to use Ada. How is it that Ada has this "super powerful", "super
> difficult", "there's not much call for it because it's too advanced
> and powerful" air about it when it's just another language? It's
> like saying that the machine code spit out of an Ada compiler has
> some mystical, magical properties that makes the Ada language more
> difficult to use.

I was thinking along the same lines last evening, and I came up with a
small theory that explains why so few pople can be bothered to learn
Ada. It goes like this: There are 3 types of languages.

The first type of language says "we're going to make programming
easy". Of course, this is a lie, because programming is inherently
difficult and no language can make it easy. These languages fake it
by being simplistic. Java is the most prominent member of this family
of languages; most scripting languages also fall in this category.
Beginners tend to flock to these "easy" languages and never learn
proper programming skills (like e.g. memory management. If some Java
"guru" reads this, ask yourself this one question: how many threads
does your program have, and please justify the existence of each
thread).

The second type says "we will let you do anything, absolutely anything
you want, and the power is in the hands of the True Programmers".
Languages in this category include, among others, C and C++. Many
people take a foolish pride in being called a True Programmer, and
therefore like these languages. I myself once was in this category: I
would show off my skills by writing a single-line program that nobody
else could read. But humans write bugs, and these languages don't
lend a hand finding these. Hence the famous buffer overflows.

The third type is what I would call the "zen master" type of
languages. They treat you like an apprentice, slapping you on the
hand each time you make a small mistake, and they scorn at you for
choosing the quick and easy path -- which leads to the Dark Side. If
you accept their teachings, you quickly become a Master yourself. If
you rebel against them, you will never achieve Enlightenment and will
always produce bugs. The "zen master" languages are Pascal, Modula,
Oberon, and, master of masters, Ada. The beauty of these languages is
that, once you are Enlightened, you can apply your wisdom to other
languages as well -- but often would prefer not to.

--
Ludovic Brenta.

David Rasmussen

unread,
Feb 7, 2004, 8:19:11 AM2/7/04
to
Ludovic Brenta wrote:
> "Carroll-Tech" <and...@carroll-tech.net> writes:
>
>
>>I tell the students that I tutor that learning some Pascal or Ada
>>would help them and they get scared. I mention doing a project in
>>Ada and everyone looks at me like I'm out to punish myself. To me
>>it isn't any easier to use C/C++, Java, Perl, Lisp or Prolog than it
>>is to use Ada. How is it that Ada has this "super powerful", "super
>>difficult", "there's not much call for it because it's too advanced
>>and powerful" air about it when it's just another language? It's
>>like saying that the machine code spit out of an Ada compiler has
>>some mystical, magical properties that makes the Ada language more
>>difficult to use.
>

I don't know. Ada rocks.

/David

David Harmon

unread,
Feb 7, 2004, 9:56:42 AM2/7/04
to
On 07 Feb 2004 14:00:35 +0100 in comp.lang.c++, Ludovic Brenta
<ludovic...@insalien.org> was alleged to have written:
>Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.lang.java

You damned crossposting troll, there is _no_ subject on-topic in all
those newsgroups.

See the welcome message posted twice per week in comp.lang.c++ or
available at http://www.slack.net/~shiva/welcome.txt

Robert I. Eachus

unread,
Feb 7, 2004, 10:03:20 AM2/7/04
to
Ludovic Brenta wrote:

> The third type is what I would call the "zen master" type of
> languages. They treat you like an apprentice, slapping you on the
> hand each time you make a small mistake, and they scorn at you for
> choosing the quick and easy path -- which leads to the Dark Side. If
> you accept their teachings, you quickly become a Master yourself. If
> you rebel against them, you will never achieve Enlightenment and will
> always produce bugs. The "zen master" languages are Pascal, Modula,
> Oberon, and, master of masters, Ada. The beauty of these languages is
> that, once you are Enlightened, you can apply your wisdom to other
> languages as well -- but often would prefer not to.

I think you are on the right track. When I am programming in Ada, I
often spend most of a day coding. If I am exhausted at the end of it, I
will put off compiling until the next day. Otherwise, I hand all the
code to the compiler, and I am not surprised to be handed back dozens of
error messages. Fix the syntax bugs, and now I get twices as many
semantic errors. Kill all those and I am surprised if the test
programs--often written between the package interface and the package
bodies--don't run correctly.

For example, I recently finished writing a library of matrix operations
which works with "views" that may be a submatrix of an existing matrix,
and supports operations like Add(A,B) where the result is written in A.
That's a bit tricky, but the real complex one is Mult(A,B) where the
amount of temporary storage space for two N by N matricies is N. (A
buffer that stores one row.)

Why am I mentioning this? After all the coding I had a bug in the Mult
routine that the compiler didn't catch. A wrong subscript inside a
loop. (Why am I doing this? To submit as a new benchmark for SPECfp.
All that stuff is just scaffolding for implementing Strassen's algorithm
efficiently.)

Since I don't take what the compiler tells me personally, I love the
ratio of a hundred to one or so between compile errors and run-time
bugs. Some people though look at a list of compiler error messages as
if each one was a major failing on their part. Me? I could proofread
the code carefully, but it is easier to let the compiler find out where
I typed a comma for a period, and so on. And IMHO it would be nice if
the compiler found all the typos, not just most of them. ;-)

Could I write the same code in C, C++, or Java? Sure. It is just much
easier to let the Ada compiler do the heavy lifting part of the
debugging, so I would still write in Ada, then modify the code to match
the C, C++, or Java syntax. So to me, all that frequent hand-slapping
is a major benefit.

--
Robert I. Eachus

"The war on terror is a different kind of war, waged capture by capture,
cell by cell, and victory by victory. Our security is assured by our
perseverance and by our sure belief in the success of liberty." --
George W. Bush

Jano

unread,
Feb 7, 2004, 11:51:21 AM2/7/04
to
Carroll-Tech dice...

> I tell the students that I tutor that learning some Pascal or Ada would help
> them and they get scared. I mention doing a project in Ada and everyone
> looks at me like I'm out to punish myself. To me it isn't any easier to use
> C/C++, Java, Perl, Lisp or Prolog than it is to use Ada. How is it that Ada
> has this "super powerful", "super difficult", "there's not much call for it
> because it's too advanced and powerful" air about it when it's just another
> language? It's like saying that the machine code spit out of an Ada
> compiler has some mystical, magical properties that makes the Ada language
> more difficult to use.

I can tell you my personal experience. My first tries at Ada where
painful: For a start, it was hard (comparatively to other languages
anyway) to get your program compiled... these damn compiler complaining
about anything. Then, I was always getting "constraint_error" and such.
Mind you, in C these errors could go unnoticed for quite some time.

In the end, when you get used to the Ada way, you realize how productive
it makes you, but at first it was exactly as you depict it.

I've always said: Ada doesn't catch with the general populace because
isn't a language for everyone: it requires extra-discipline and other
qualities from the programmer. It's like fast-food and sane food:
everyone knows the later is better, but not everyone has the will to
renounce to the first. In the 20/80 rule, Ada is for the better 20% of
the programmers... or so I like to think ;)

Ed Falis

unread,
Feb 7, 2004, 12:53:04 PM2/7/04
to
On Sat, 7 Feb 2004 17:51:21 +0100, Jano <no...@unizar.es> wrote:
> Ada is for the better 20% of
> the programmers... or so I like to think ;)

I wouldn't be so self-congratulatory. I really don't think there's much
correlation here between programming skills and language choice.

What I do find is that the strength of the Ada compiler lessens my need
for certain kinds of self-discipline to some extent, and works much like
doing unit tests (or pair programming from XP) and having a facility for
design-by-contract do. It provides an additional automated safety net to
complement whatever the state of my self-discipline might be at a given
time. SPARK, I'm sure, does the same at a more "brisk" level.

But don't think that Ada is alone in providing such safety nets - there
are other languages and other techniques that can do as much or more,
depending on the emphasis on different issues in a given development
effort.

disclosure: I've been involved in implementing Ada since 1980-1.

- Ed

MSG

unread,
Feb 7, 2004, 2:24:47 PM2/7/04
to
Ludovic Brenta <ludovic...@insalien.org> wrote in message news:<m3isij11...@insalien.org>...

[...]

> The "zen master" languages are Pascal, Modula,
> Oberon, and, master of masters, Ada. The beauty of these languages is
> that, once you are Enlightened, you can apply your wisdom to other
> languages as well -- but often would prefer not to.


Can you do the following in Ada:

1. Write *one* bubble-sort function that will work on different
types given an appropriate comparison function

2. If B is a subtype of A, can you pass it to any function that
takes A as an argument? (covariance)

3. If B is a subtype of A, and FA and FB are functions accepting A
and B as arguments, can you use FA wherever FB could be used?
(contravariance)

4. If B is a subtype of A, is list/array/vector/set/etc. of Bs a
subtype of list/array/vector/set/etc of As? (covariance)

Unless you can show us how to do this in a way that will keep Ada a
"safe" (third category) language you say it is, I will not believe
that it's a "master of of the masters", I'm afraid.

If you answer "yes" to any of the questions, post *compilable*
snippets: we don't want to learn Ada just to verify your claims,
we simply won't believe you.

BTW, the esteemed Mr. E. Robert Tisdale (ER for short) isn't
letting on about why Ada isn't used much at NASA any more.
Perhaps *you* have an explanation?

MSG

David Rasmussen

unread,
Feb 7, 2004, 2:32:29 PM2/7/04
to
MSG wrote:
>
> Unless you can show us how to do this in a way that will keep Ada a
> "safe" (third category) language you say it is, I will not believe
> that it's a "master of of the masters", I'm afraid.
>
> If you answer "yes" to any of the questions, post *compilable*
> snippets: we don't want to learn Ada just to verify your claims,
> we simply won't believe you.
>
> BTW, the esteemed Mr. E. Robert Tisdale (ER for short) isn't
> letting on about why Ada isn't used much at NASA any more.
> Perhaps *you* have an explanation?
>

So you have theories about Ada, but you don't really know it? That's
credible...

Just for the record: I am posting from comp.lang.c++.

/David

Alexandre E. Kopilovitch

unread,
Feb 7, 2004, 4:03:25 PM2/7/04
to comp.l...@ada-france.org
Ludovic Brenta wrote:

> The third type is what I would call the "zen master" type of
> languages. They treat you like an apprentice, slapping you on the
> hand each time you make a small mistake, and they scorn at you for
> choosing the quick and easy path -- which leads to the Dark Side. If
> you accept their teachings, you quickly become a Master yourself.

No, this way you have a little chance for that. Following this way you'll
most probably become more or less respectable member of the guild, a master,
but not Master. Just because you are deprived from Dark Side, and every Master
must know it from good personal experience (some manage to get it from their
own imagination, but this is very rare case, as it requires exceptionally
strong imagination abilities... and exceptional abilities for keeping mental
balance as well).

> If you rebel against them,

Actually you must rebel against something if you want to achieve anything
significantly above average. Surely, it isn't necessary to rebel against your
master personally, but a rebellion against some widespread and respectable
opinion is almost inevitable for such a "graduation".

> you will never achieve Enlightenment and will always produce bugs.

You will produce bugs anyway, with or without Enlightenment -;) . And I'm
afraid that in this your description Enlightenment doesn't seem different
from Doctrine -;) .

> The "zen master" languages are Pascal, Modula,
> Oberon, and, master of masters, Ada.

I don't think so - there is vast amount of various "zens" and "zen masters"
for C++, Java... Smalltalk, Lisp, etc (even COBOL had at least one "zen", and
I remember that it was a good one). And all those "zen masters" feel themselves
quite comfortable with their accustomed languages.


Alexander Kopilovitch a...@vib.usr.pu.ru
Saint-Petersburg
Russia

Keith Thompson

unread,
Feb 7, 2004, 5:47:55 PM2/7/04
to
msg...@yahoo.com (MSG) writes:
> If you answer "yes" to any of the questions, post *compilable*
> snippets: we don't want to learn Ada just to verify your claims,
> we simply won't believe you.

Feel free to post compilable Ada snippets in comp.lang.ada, but please
don't cross-post to comp.lang.c, comp.lang.c++, or comp.lang.java.
The last thing any of these newsgroups needs is yet another language
flame war. (I'm posting from comp.lang.c.)

I've redirected followups to comp.lang.ada.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"

tmo...@acm.org

unread,
Feb 7, 2004, 6:19:15 PM2/7/04
to
>4. If B is a subtype of A, is list/array/vector/set/etc. of Bs a
> subtype of list/array/vector/set/etc of As? (covariance)
What do you mean by a "set" being a "subtype" of another "set"?

David Starner

unread,
Feb 7, 2004, 7:25:33 PM2/7/04
to
On Sat, 07 Feb 2004 14:00:35 +0100, Ludovic Brenta wrote:

> Of course, this is a lie, because programming is inherently
> difficult and no language can make it easy.

That's exactly what the assembly language programmers said about the
first Fortran compiler, and it's equally wrong now. Sure, there are cases
where you need to run DSP code and coordinate with the home base thirty
million miles away using one space-hardened 386, and that's hard. Then
there's the cases where you need two lines of shell to simplify moving
files around, and that's something assembly or Fortran or Ada or Java
would make much more complex then it is.

> (like e.g. memory management. If some Java
> "guru" reads this, ask yourself this one question: how many threads
> does your program have, and please justify the existence of each
> thread).

In the Jargon file, there's a story of a man who bummed every cycle out of
a poker program, even the initialization code, who spurned assembly
language because it was too inefficient. How would you explain your choice
of programming language to him? Who cares if there's a couple extra
threads running? You make a big deal about languages that protect you
against buffer overflows, why not use a language that protects you against
memory leaks?

> The "zen master" languages are Pascal, Modula,
> Oberon, and, master of masters, Ada.

Pascal is hardly usable, unless you use one of a dozen proprietary
extensions. That's hardly "zen master".

Ludovic Brenta

unread,
Feb 7, 2004, 8:00:01 PM2/7/04
to
David Starner <dvd...@email.ro> writes:

> On Sat, 07 Feb 2004 14:00:35 +0100, Ludovic Brenta wrote:
>
> > Of course, this is a lie, because programming is inherently
> > difficult and no language can make it easy.
>
> That's exactly what the assembly language programmers said about the
> first Fortran compiler, and it's equally wrong now. Sure, there are cases
> where you need to run DSP code and coordinate with the home base thirty
> million miles away using one space-hardened 386, and that's hard. Then
> there's the cases where you need two lines of shell to simplify moving
> files around, and that's something assembly or Fortran or Ada or Java
> would make much more complex then it is.

If you call this programming, then you're right. Scripting languages
do have a place and purpose. I was more concerned with large-scale,
real-world programming, where Ada shines but is being ignored by too
many people. I was only trying to explain to myself why. I stand by
my claim that no language can make programming easy. But a language
help you find, or avoid, bugs.

> > (like e.g. memory management. If some Java
> > "guru" reads this, ask yourself this one question: how many threads
> > does your program have, and please justify the existence of each
> > thread).
>
> In the Jargon file, there's a story of a man who bummed every cycle out of
> a poker program, even the initialization code, who spurned assembly
> language because it was too inefficient. How would you explain your choice
> of programming language to him?

I would ask him, "would you trust your own life to your program"?

> Who cares if there's a couple extra threads running? You make a big
> deal about languages that protect you against buffer overflows, why
> not use a language that protects you against memory leaks?

Because I want to control exactly how much memory my program uses, and
I want to know exactly how many "a couple" means, and why these
"couple" threads are necessary. You referred to embedded software for
space-bound devices, this is one area where these questions are really
important. I am willing to accept run-time inefficiency and "a couple
extra threads" if justified. There are some languages that force
these upon you and won't justify this cost.

> > The "zen master" languages are Pascal, Modula,
> > Oberon, and, master of masters, Ada.
>
> Pascal is hardly usable, unless you use one of a dozen proprietary
> extensions. That's hardly "zen master".

That is true, but I meant "master" in the sense of "teacher". Pascal
was quite good at teaching, and as a "master" it had quite a lot of
apprentices.

--
Ludovic Brenta.

David Starner

unread,
Feb 7, 2004, 9:29:05 PM2/7/04
to
On Sun, 08 Feb 2004 02:00:01 +0100, Ludovic Brenta wrote:

> I was more concerned with large-scale,
> real-world programming, where Ada shines but is being ignored by too
> many people.

Ah, so that wasn't in the real world. Thanks for clarifying that.

> I was only trying to explain to myself why. I stand by
> my claim that no language can make programming easy. But a language
> help you find, or avoid, bugs.

But that's not the goal of programming. The goal of programming is to
produce programs that get the job done. There are certainly languages that
remove the concern about memory usage, and allow you to easily handle
strings and databases and GUIs, and these languages certainly do make it
easier to solve certain classes of programs. If they're slower and take
more memory, no one cares. If they have a few bugs, well, they get worked
around.


> I would ask him, "would you trust your own life to your program"?

He would tell you of course, and ask you how you could trust your life to
a program automatically produced by a compiler you know to be buggy.

I might point out that his program doesn't require that you trust your
life to it. Not everything is life and death, and a lot of things require
writing the program quickly or having the program run quickly over
absolute correctness.



> Because I want to control exactly how much memory my program uses,

So you're anal. There are very few programs that push my computer, with
300 MB of RAM to swap. Worrying about 10% memory usage on the rest in
exchange for occasional crashes is not a good tradeoff.

> You referred to embedded software for
> space-bound devices, this is one area where these questions are really
> important.

Yes, but you missed the point. That's one class of software, and
there's probably not a million lines of code written a year for that
class; probably not one percent of the code written for PCs with 1 GB of
memory that won't use over a few MB in practice.

> There are some languages that force these
> upon you and won't justify this cost.

But you aren't the one being asked to justify it; you are telling other
programmers that it's unjustified. Perhaps the inefficiency is justified
to them.

> Pascal
> was quite good at teaching, and as a "master" it had quite a lot of
> apprentices.

Java has a lot of apprentices, too. Pascal has something to do with the
number of people who refused to look at Ada, in the way that it forced
everyone into this tiny box, without modules or generics or bit twiddling
and all in one file.

Nick Landsberg

unread,
Feb 7, 2004, 9:54:55 PM2/7/04
to

David Starner wrote:

> On Sat, 07 Feb 2004 14:00:35 +0100, Ludovic Brenta wrote:
>
>
>>Of course, this is a lie, because programming is inherently
>>difficult and no language can make it easy.
>
>
> That's exactly what the assembly language programmers said about the
> first Fortran compiler, and it's equally wrong now. Sure, there are cases
> where you need to run DSP code and coordinate with the home base thirty
> million miles away using one space-hardened 386, and that's hard. Then
> there's the cases where you need two lines of shell to simplify moving
> files around, and that's something assembly or Fortran or Ada or Java
> would make much more complex then it is.
>
>
>>(like e.g. memory management. If some Java
>>"guru" reads this, ask yourself this one question: how many threads
>>does your program have, and please justify the existence of each
>>thread).
>
>
> In the Jargon file, there's a story of a man who bummed every cycle out of
> a poker program, even the initialization code, who spurned assembly
> language because it was too inefficient. How would you explain your choice
> of programming language to him? Who cares if there's a couple extra
> threads running? You make a big deal about languages that protect you
> against buffer overflows, why not use a language that protects you against
> memory leaks?

"Who cares it there's an extra couple of threads running?" you ask.
I do! I work on systems which are required to process thousands
of requests per second. Unnecessary threads (just because the language
makes it easy to create them), waste precious CPU cycles. (But that's
OT in c.l.c, I think).

If your last statement refers to Java protecting you against memory
leaks, then you have a surprise in store for you.
If it protects you against memory leaks why is there a need for
a garbage collector in the first place?
I have found many situations where the garbage collector did
not clear unused memory. The garbage collector is just as
buggy as any other code. (This is also OT in the c.l.c group.
and I don't want to subsribe to c.l.java :)

>
>
>>The "zen master" languages are Pascal, Modula,
>>Oberon, and, master of masters, Ada.
>
>
> Pascal is hardly usable, unless you use one of a dozen proprietary
> extensions. That's hardly "zen master".
>

--
Ñ
"It is impossible to make anything foolproof because fools are so
ingenious" - A. Bloch

Ludovic Brenta

unread,
Feb 7, 2004, 10:15:55 PM2/7/04
to

Dear "MSG", I do not normally respond to people who won't tell me
their name. Nevertheless, I found your questions interesting, so here
goes.

msg...@yahoo.com (MSG) writes:

> Ludovic Brenta <ludovic...@insalien.org> wrote...


>
> [...]
>
> > The "zen master" languages are Pascal, Modula,
> > Oberon, and, master of masters, Ada. The beauty of these languages is
> > that, once you are Enlightened, you can apply your wisdom to other
> > languages as well -- but often would prefer not to.
>
>
> Can you do the following in Ada:
>
> 1. Write *one* bubble-sort function that will work on different
> types given an appropriate comparison function

Yes you can, using generics. This is actually part of the library
that comes with the GNAT compiler.

See the spec for the package at http://savannah.gnu.org/cgi-bin/viewcvs/gcc/gcc/gcc/ada/g-busorg.ads?rev=HEAD&content-type=text/vnd.viewcvs-markup

And the body at http://savannah.gnu.org/cgi-bin/viewcvs/gcc/gcc/gcc/ada/g-busorg.adb?rev=HEAD&content-type=text/vnd.viewcvs-markup.



> 2. If B is a subtype of A, can you pass it to any function that
> takes A as an argument? (covariance)

Yes, as illustrated below. Covariance, as far as I understand, is the
capability to override the function using B as a type for both the
parameter and the return type. Ada has this capability. Note that
Ada has no hidden "this" parameter; everything is explicit.

with Ada.Text_IO; use Ada.Text_IO;
procedure Covariance is
package P is
type A is tagged null record;
function Operation (This : A) return A;
procedure Some_Primitive_Operation (Parameter : in out A);

type B is new A with null record;
function Operation (This : B) return B;
-- is a covariant function: the types of the parameter and the return
-- type vary together
end P;

package body P is
function Operation (This : A) return A is
begin
Put_Line ("Operation on A");
return This;
end Operation;

procedure Some_Primitive_Operation (Parameter : in out A) is
begin
Put_Line ("This accepts A or any derived type thereof");
end Some_Primitive_Operation;

function Operation (This : B) return B is
begin
Put_Line ("Operation on B");
return This;
end Operation;
end P;

use P;

My_First_A, My_Second_A : A;
My_First_B, My_Second_B : B;

begin
My_Second_A := Operation (This => My_First_A);
My_Second_B := Operation (This => My_First_B);
Some_Primitive_Operation (Parameter => My_Second_B);
end Covariance;

> 3. If B is a subtype of A, and FA and FB are functions accepting A
> and B as arguments, can you use FA wherever FB could be used?
> (contravariance)

I'm not sure I understand what you mean. Does the following code
answer your question? If it doesn't, please post a compilable code
snippet in your preferred language.

with Ada.Text_IO; use Ada.Text_IO;
procedure Contravariance is
package P is
type A is tagged null record;
function Func (This : in A) return A'Class; -- this would be FA

type B is new A with null record;
function Func (This : in B) return A'Class; -- this would be FB
end P;

package body P is
function Func (This : in A) return A'Class is
begin
Put_Line ("Func on A");
return This;
end Func;

function Func (This : in B) return A'Class is
begin
Put_Line ("Func on B");
return This;
end Func;
end P;

use P;

My_First_A, My_Second_A : A;
My_First_B, My_Second_B : B;

begin
My_First_A := A (Func (My_First_A)); -- explicit conversion to type A
My_Second_A := A (Func (My_First_B)); -- explicit conversion to type A
end Contravariance;

> 4. If B is a subtype of A, is list/array/vector/set/etc. of Bs a
> subtype of list/array/vector/set/etc of As? (covariance)

Not automatically. You would define new containers explicitly for A
and B, using generics; see for example the Booch components[1] or the
Charles library[2], which is modelled after the C++ STL. If you want
polymorphic containers, you store pointers in them.

[1] http://www.pogner.demon.co.uk/components/bc/case-study.html
[2] http://home.earthlink.net/~matthewjheaney/charles/

> Unless you can show us how to do this in a way that will keep Ada a
> "safe" (third category) language you say it is, I will not believe
> that it's a "master of of the masters", I'm afraid.

I cannot show you something you refuse to see (you say you won't learn
Ada). But if you are curious and intellectually honest, you will see
that Ada is indeed safer almost all other languages.

If Ada is not safe enough for you (even though it is for Boeing and
Airbus and the French TGV), then look into SPARK[3]. SPARK is a
subset of Ada where dynamic memory allocation and several other
potentially dangerous constructs are forbidden. When I say "subset",
I mean that any Ada compiler can compile any SPARK program. It also
adds design by contract à la Eiffel, using a tool called the
"Examiner" that complements the compiler.

[3] http://www.sparkada.com

> If you answer "yes" to any of the questions, post *compilable*
> snippets: we don't want to learn Ada just to verify your claims,
> we simply won't believe you.

You would be well advised to learn Ada. If you don't do it just to
verify my claims, do it to better your understanding of safety,
maintainability and large-scale programming in general. As I said, if
you accept to be given lessons, you can then reapply this insight to
your language of choice.

> BTW, the esteemed Mr. E. Robert Tisdale (ER for short) isn't
> letting on about why Ada isn't used much at NASA any more.
> Perhaps *you* have an explanation?

My earlier post was an attempt at an explanation. To rephrase it
shortly, few people are willing to be slapped on the hand by the
compiler every time they make a mistake; they'd rather ship buggy
software to customers ("True Programmers"), or use a language that
makes critical decisions unbeknownst to them ("Programming made
easy"). This explanation, of course, is just a theory of mine and is
a caricature more than an accurate description of reality.

--
Ludovic Brenta.

Simon Wright

unread,
Feb 8, 2004, 7:12:44 AM2/8/04
to
"Robert I. Eachus" <riea...@comcast.net> writes:

> I think you are on the right track. When I am programming in Ada, I
> often spend most of a day coding. If I am exhausted at the end of it,
> I will put off compiling until the next day. Otherwise, I hand all
> the code to the compiler, and I am not surprised to be handed back
> dozens of error messages. Fix the syntax bugs, and now I get twices
> as many semantic errors.

I don't know if I'm just too impatient, but I much prefer to implement
each subprogram body and then compile it (they are usually separates,
so GNAT is quite happy do do this from within Glide).

If nothing else, it means that any problems with specs or
inter-package relationships appear earlier.

> Kill all those and I am surprised if the
> test programs--often written between the package interface and the
> package bodies--don't run correctly.

--
Simon Wright 100% Ada, no bugs.

Martin Krischik

unread,
Feb 8, 2004, 7:57:07 AM2/8/04
to
Ludovic Brenta wrote:

> Not automatically. You would define new containers explicitly for A
> and B, using generics; see for example the Booch components[1] or the
> Charles library[2], which is modelled after the C++ STL. If you want
> polymorphic containers, you store pointers in them.

AdaCL (adacl.sf.net) has polymorphic containers whichout (exposed) pointers
- that is somthing C++ can't do ;-) because C++'s RTTI is only a cheap
excuse compared with Ada's tags.

For the C++ programmes: If you copy contruct a class in Ada then Ada will
use the tag of the class to determine the actual child class and copy that
instead of the currently visible prarent view of the class.

With Regards

Martin
--
mailto://kris...@users.sourceforge.net
http://www.ada.krischik.com

Martin Krischik

unread,
Feb 8, 2004, 8:05:53 AM2/8/04
to
MSG wrote:

> Ludovic Brenta <ludovic...@insalien.org> wrote in message
> news:<m3isij11...@insalien.org>...
>
> [...]
>
>> The "zen master" languages are Pascal, Modula,
>> Oberon, and, master of masters, Ada. The beauty of these languages is
>> that, once you are Enlightened, you can apply your wisdom to other
>> languages as well -- but often would prefer not to.
>
>
> Can you do the following in Ada:
>
> 1. Write *one* bubble-sort function that will work on different
> types given an appropriate comparison function

Shure you can. Ada invented templates long bevore C++ was even though of.
Ada templates are far more powerfull then C++.

> 2. If B is a subtype of A, can you pass it to any function that
> takes A as an argument? (covariance)

subtype as in object orientation:

type Parent is tagged null record;
type Child is new Parent with null record;

or subtype as in simple types:

type Day_of_Month is range 1 .. 31;
subtype Day_of_Febuary is Day_of_Month range 1 .. 29;

Well, the answer is yes in both cases.

> 3. If B is a subtype of A, and FA and FB are functions accepting A
> and B as arguments, can you use FA wherever FB could be used?
> (contravariance)

Of corse.



> If you answer "yes" to any of the questions, post *compilable*
> snippets: we don't want to learn Ada just to verify your claims,
> we simply won't believe you.

Others did that allready. Besides, you would need an installed Ada compiler
to verify anyway.



> BTW, the esteemed Mr. E. Robert Tisdale (ER for short) isn't
> letting on about why Ada isn't used much at NASA any more.

He also won't tell you why Spirit died.

Alexandre E. Kopilovitch

unread,
Feb 8, 2004, 11:02:50 AM2/8/04
to comp.l...@ada-france.org
David Starner wrote:

> The goal of programming is to produce programs that get the job done.

Your employer must be satisfied with that statement -:) , but as you put it
here instead of your resume, I must tell you that this statement is severely
flawed. Programming is not covered by compilation and scripting. Generally,
major part of programming is to define precisely and formally, *what* is the
job, and what does it mean that this job *is done*. For a compilation-like job
both definitions are prerequisites, and for scripting some imprecise and
informal understanding of them very often is enough, but for other flavours
of programming this is major part of the goal.

(As an exercise you may try to define that - what is the job and what means
that this job is done - for a "good text editor"... better to do that exercise
within a group of your fellow programmers -:) .

Josh Sebastian

unread,
Feb 8, 2004, 11:20:17 AM2/8/04
to
On Sun, 08 Feb 2004 14:05:53 +0100, Martin Krischik wrote:

> MSG wrote:
>
>> Can you do the following in Ada:
>>
>> 1. Write *one* bubble-sort function that will work on different
>> types given an appropriate comparison function
>
> Shure you can. Ada invented templates long bevore C++ was even though of.

Factoid: Alex Stepanov started off his research that led to the STL in Ada.

> Ada templates are far more powerfull then C++.

Why do you say that? I haven't used Ada terribly much, but from what I
remember, I don't think Ada generics are Turing-complete, which C++
templates are.

Josh

Martin Krischik

unread,
Feb 8, 2004, 1:02:02 PM2/8/04
to
Josh Sebastian wrote:

> On Sun, 08 Feb 2004 14:05:53 +0100, Martin Krischik wrote:
>
>> MSG wrote:
>>
>>> Can you do the following in Ada:
>>>
>>> 1. Write *one* bubble-sort function that will work on different
>>> types given an appropriate comparison function
>>
>> Shure you can. Ada invented templates long bevore C++ was even though of.
>
> Factoid: Alex Stepanov started off his research that led to the STL in
> Ada.

I am not quite shure what you want to say. As far as I know generics had
been part of Ada 83. But of course without some STL.

>> Ada templates are far more powerfull then C++.
>
> Why do you say that? I haven't used Ada terribly much, but from what I
> remember, I don't think Ada generics are Turing-complete, which C++
> templates are.

Well I have used C++ for 10 years and Ada for just 1 year - I can express my
will better with Ada generics then with C++ templates.

Josh Sebastian

unread,
Feb 8, 2004, 2:06:11 PM2/8/04
to
On Sun, 08 Feb 2004 19:02:02 +0100, Martin Krischik wrote:

> Josh Sebastian wrote:
>
>> On Sun, 08 Feb 2004 14:05:53 +0100, Martin Krischik wrote:
>>
>> Factoid: Alex Stepanov started off his research that led to the STL in
>> Ada.
>
> I am not quite shure what you want to say.

I was saying that the STL started off in Ada before it was moved to (and
completed in) C++. I wasn't disagreeing with you (yet :).

>>> Ada templates are far more powerfull then C++.
>>
>> Why do you say that? I haven't used Ada terribly much, but from what I
>> remember, I don't think Ada generics are Turing-complete, which C++
>> templates are.
>
> Well I have used C++ for 10 years and Ada for just 1 year - I can express my
> will better with Ada generics then with C++ templates.

Maybe you just weren't very good at C++ templates. I don't mean to be
insulting, but personal preferences do play a huge roll here. Unless
someone can prove Ada's generics are Turing-complete, though (a quick
google doesn't turn up anything), I'd say that we'll have to call C++
templates more powerful.

Josh

Martin Ambuhl

unread,
Feb 8, 2004, 3:39:36 PM2/8/04
to
Josh Sebastian and Martin Krischik are continuing their silly language
advocacy.
Perhaps comp.lang.ada cares about the preference of one for Ada;
perhaps comp.lang.c++. Who knows what the people in comp.lang.java care
about? I know for damn sure that comp.lang.c is not the place for your
silly discussion of Ada vs. C++.
I have set follow-ups to comp.lang.ada and comp.lang.c++. Even that might
be too much. In any event, take comp.lang.c off any future exchanges you
idiots have. Even better: take it to e-mail.

--
Martin Ambuhl

David Starner

unread,
Feb 8, 2004, 3:55:57 PM2/8/04
to
On Sun, 08 Feb 2004 19:02:50 +0300, Alexandre E. Kopilovitch wrote:

> David Starner wrote:
>
>> The goal of programming is to produce programs that get the job done.
>

> [...] I must tell you that this statement is severely


> flawed. Programming is not covered by compilation and scripting. Generally,
> major part of programming is to define precisely and formally, *what* is the
> job, and what does it mean that this job *is done*.

And once you have the program at a state where it needs no more
programming, all that goes into a drawer and disappears. That is part of
what needs to be done to get a program that gets the job done, but that's
not part of the goal; that's part of the process.

MSG

unread,
Feb 8, 2004, 6:25:26 PM2/8/04
to
Martin Krischik <kris...@users.sourceforge.net> wrote in message news:<2460735.u...@linux1.krischik.com>...

> Others did that allready. Besides, you would need an installed Ada compiler
> to verify anyway.

time apt-get install gnat
=> 15 seconds

> >
> > Can you do the following in Ada:
> >
> > 1. Write *one* bubble-sort function that will work on different
> > types given an appropriate comparison function
>
> Shure you can. Ada invented templates long bevore C++ was even though of.
> Ada templates are far more powerfull then C++.

Example?

> > 2. If B is a subtype of A, can you pass it to any function that
> > takes A as an argument? (covariance)
>
> subtype as in object orientation:
>
> type Parent is tagged null record;
> type Child is new Parent with null record;

"null record" ? How about non-null ones? Is a 3D point (x, y, z) a
subtype of a 2D one (x, y) ?

BTW, does Ada have discriminated unions? (if you don't know what they
are, probably none of the language you used had them)

Also, is it possible to corrupt memory in Ada?
Is it possible to leak memory in Ada?

> or subtype as in simple types:
>
> type Day_of_Month is range 1 .. 31;
> subtype Day_of_Febuary is Day_of_Month range 1 .. 29;

That's neat.



> > BTW, the esteemed Mr. E. Robert Tisdale (ER for short) isn't
> > letting on about why Ada isn't used much at NASA any more.
>
> He also won't tell you why Spirit died.

It's not dead, it's sleeping!

Cheers,
MSG

James Rogers

unread,
Feb 8, 2004, 7:11:53 PM2/8/04
to
Given the quite reasonable objections presented by some in the
cross-posted news-groups I would like to carry on this conversation
with you via email. My return email is valid.

Jim Rogers

Ludovic Brenta

unread,
Feb 8, 2004, 8:24:58 PM2/8/04
to
msg...@yahoo.com (MSG) writes:

> Martin Krischik <kris...@users.sourceforge.net> wrote:
>
> > Others did that allready. Besides, you would need an installed Ada compiler
> > to verify anyway.
>
> time apt-get install gnat
> => 15 seconds

Thanks, I made that package :)

> > >
> > > Can you do the following in Ada:
> > >
> > > 1. Write *one* bubble-sort function that will work on different
> > > types given an appropriate comparison function
> >
> > Shure you can. Ada invented templates long bevore C++ was even though of.
> > Ada templates are far more powerfull then C++.
>
> Example?

I gave one earlier on c.l.ada. I did not cross-post it to the other
newsgroups.

Ada templates are superior to C++ templates in several respects. For
one thing, you can pass procedures and functions as generic
parameters, and the generic formal parameters specify the signature
for them. Another thing is that the generic formal parameters can
specify several kinds of restrictions to types that are acceptable.

> > > 2. If B is a subtype of A, can you pass it to any function that
> > > takes A as an argument? (covariance)
> >
> > subtype as in object orientation:
> >
> > type Parent is tagged null record;
> > type Child is new Parent with null record;
>
> "null record" ? How about non-null ones? Is a 3D point (x, y, z) a
> subtype of a 2D one (x, y) ?

type Point_2D is tagged record
X, Y : Float;
end record;

type Point_3D is new Point_2D with record
Z : Float;
end record;

> BTW, does Ada have discriminated unions? (if you don't know what they
> are, probably none of the language you used had them)

Yes, they are called variant records.

> Also, is it possible to corrupt memory in Ada?

Yes, if you try hard enough and use Unchecked_Conversion and
System.Address instead of the more usual stuff. Very hard in
practice. I once tried to do a buffer overflow in Ada, and managed
it, but the code to achieve this is rather ugly. Basically, you have
to go the extra mile to corrupt memory in Ada.

> Is it possible to leak memory in Ada?

Yes, just like in C. However, since Ada programmers do much less
dynamic memory allocation, this happens much less often than it does
in C. Note that there also exists a garbage collector in Ada, as part
of AdaCL.

> > or subtype as in simple types:
> >
> > type Day_of_Month is range 1 .. 31;
> > subtype Day_of_Febuary is Day_of_Month range 1 .. 29;
>
> That's neat.

If this is neat then dig this:

for J in Day_Of_Month loop
exit when Month = February and then J >= Day_Of_February'Last;
Put_Line (Day_Of_Month'Image (J));
end loop;

And think about the implications of these ranges on subprograms that
accept only a small set of integer constants as a parameter:

type Assessment is (Yes, No, Maybe, Maybe_Not);

procedure P (A : Assessment);

which is not possible in C:

typedef enum { YES, NO, MAYBE, MAYBE_NOT } assessment_t;

void P (assessment_t A) { }

int main () {
P (42); // no compiler check!
return 0;
}

I just tried the above with gcc -Wall and got no warning. This means
that only a human carefully reviewing this program will see the
mistake (you may also try lint, but this is a tool external to the
language and based on heuristics, not language rules). By contrast,
the Ada compiler catches the mistake automatically in seconds and
leaves you with the confidence that 100% of your code has been
screened for such stupid mistakes.

--
Ludovic Brenta.

Robert I. Eachus

unread,
Feb 8, 2004, 9:36:37 PM2/8/04
to
Simon Wright wrote:

> I don't know if I'm just too impatient, but I much prefer to implement
> each subprogram body and then compile it (they are usually separates,
> so GNAT is quite happy do do this from within Glide).
>
> If nothing else, it means that any problems with specs or
> inter-package relationships appear earlier.

We all have our different styles. I find when I have a design worked
out I am better off "slinging" code while it is all in my head, then
starting fresh when debugging. However, I usually do the specs in a
batch, compile them cleanly, then do the bodies. Even though there are
much fewer lines of code in the specs, they take about as much time to
write as the package bodies.

(Incidently, I cut the distribution on this to comp.lang.ada only.)