Re: Ada design (Norman H. Cohen)
31 Jan 1996 23:31:36 -0500

          From comp.compilers

Related articles
Possible to write compiler to Java VM? (I volunteer to summarize) (Peter Seibel) (1996-01-17)
Re: Possible to write compiler to Java VM? (1996-01-29)
Re: Possible to write compiler to Java VM? (1996-01-30)
Re: Ada design (1996-01-31)
Re: Ada design (1996-01-31)
Re: Ada design (1996-02-01)
Re: Ada design (1996-02-02)
Re: Ada design (1996-02-02)
Re: Ada design (1996-02-04)
| List of all articles for this month |

From: (Norman H. Cohen)
Newsgroups: comp.lang.ada,comp.compilers
Date: 31 Jan 1996 23:31:36 -0500
Organization: IBM T.J. Watson Research Center
References: 96-01-037 96-01-116 96-01-130
Keywords: translator, Ada

Norman H. Cohen <> wrote:
|> When an Ada compiler rejects my source,
|> it is because compile-time consistency checks have caught me trying to
|> do something that does not make sense. I am grateful to have had the
|> mistake caught before I wasted hours debugging. I am far more
|> frustrated by C compilers that happily compile code containing the
|> kind of errors that an Ada compiler would have caught. (Daniel J. Salomon) writes:
|> I would bet that a lot of the code that you wrote and was rejected by
|> an Ada compiler was not that illogical or unsafe. I bet that most of
|> it was actually pretty reasonable.

I'm afraid you would lose that bet. Most of my compile-time error
messages report typographical and clerical errors. An Ada compiler does
not consider

      if A := 0 then
      end if;

to be "pretty reasonable" and decide that I mean to assign zero to A!
Some of my compile-time errors reflect confusion, e.g. trying to pass
a pointer to an object of type T to a subprogram that expects a
pointer to an array of objects of type T. Rather than excusing this
as "not that illogical and unsafe", an Ada compiler rejects the code,
saving me from the hours of debugging I might face if I made an
analogous error in C.

|> Ada's philosophy seems to be, "When in doubt, forbid it." As a
|> result, a programmer can spend a lot of time turning sensible safe
|> code into code that religiously observes all of Ada rules.

If the programmer starts off with an understanding of data
abstraction, an appreciation of the value of distinguishing
pointer-to-T from pointer-to-array-of-T, a willingness to type a few
more keystrokes in the rare case when it is appropriate to bypass this
distinction, and a basic familiarity with the programming language,
then there is no need "turn code into" legal code. It is easy to
write Ada code that is (except for a few clerical errors) correct in
the first place.

|> C's philosopy seems to be, "When in doubt, permit it. It just might
|> be correct." The freedom that this gives programmers to create new
|> ways of solving problems may be one of the reasons that C remains so
|> popular, despite the fact that it it unquestionably unsafe.

Mostly, it gives programmers freedom to create new problems that have
to be solved. Virtually any sensible C computation can be expressed
straightforwardly in Ada, although you may have to add a few explicit
conversions here and there so that the compiler can distinguish
intentional violations of type distinctions from unintentional ones.
This gives programmers the freedom to concentrate on conceiving and
implementing solutions instead of hunting down bugs.

Norman H. Cohen

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.