comp.lang.ada
 help / color / mirror / Atom feed
From: Craig Burley <burley@tweedledumb.cygnus.com>
Subject: Re: Fortran or Ada?
Date: 1998/09/26
Date: 1998-09-26T00:00:00+00:00	[thread overview]
Message-ID: <y63e9fjt7l.fsf@tweedledumb.cygnus.com> (raw)
In-Reply-To: 6uenvf$g9a$1@nnrp1.dejanews.com

dewarr@my-dejanews.com writes:

> In article <y6sohhr11s.fsf@tweedledumb.cygnus.com>,
> 
>   Craig Burley <burley@tweedledumb.cygnus.com> wrote:
> 
> > IMO, you're absolutely right.  And, yes, a typo such as "**" for "*"
> > should produce a diagnostic, but I suspect both Fortran and C suffer
> > from this sort of thing much more than does Ada, simply because Ada
> > is a more recent language and was, I gather, more thoughtfully designed
> > than some other recent languages.
> 
> Craig, surely you do not know Ada in writing the above!

I didn't say I *did* know Ada -- in fact, I don't!

> The character * never has syntactic significance other
> than as a multiplication operator, and ** is exponentiation.

Oh, in that case, then, you're right, it's impossible to expect
a diagnostic for typos involving "normal math" expressions in a
language designed to support such things "natively".

> One could argue that it is unwise to use ** as exponentiation
> precisely because of this one character differentiation, but
> that seems a bit extreme to me!

Especially since an alternative, like BASIC's `^', still suffers
from a one-character mistake (a two-key-distance difference on
my keyboard, anyway).  Same for `+' vs. `-', etc.

What I thought might be the case was that `**' was substituted
in place of `*' in something non-mathematical, e.g. like C's
`char *foo;'.  In that example, such a typo can lead to really
hard-to-track-down behavior, and only programmers highly experienced
with that particular area of the language (C declarations) are
likely to spot it.  (These programmers will have tended to "trade
off" expertise in the application area.  While working at Cadence,
I once spotted exactly this sort of bug while looking over a
co-workers' shoulder as he and one or two others had been debugging
this bug, involving portability and reproducability problems, for hours.
The reason I was able to spot it wasn't due to any genius on my part --
in fact, I had little understanding of what the code was trying to do
in the larger sense, so I had no choice but to concentrate on the
minutiae.)

It's in the notations outside of the typical programmer's "life
expertise" that language designers must be extra-careful to
avoid constructs in which common typographical mistakes lead
to bizarre bugs, IMO.  And priority should be given to avoid
the most hard-to-see typos in general anyway: `.' vs. `,', `:' vs.
`;', `0' vs. `O', `1' vs. `l' vs. `I' vs. `!', and so on.

E.g. it is much worse that FORTRAN 77 allows the `.' typo for `,'
creating

	DO 10 I=1.6

than that it allows the `+' typo for `*' creating

	CIRC=PI+RADIUS

because the "expected" audience will spot the latter, "math" error
much more easily than the error in the imperative construct (DO).

Similarly, C's `=' vs. `==' is a pretty bad problem -- though long-
sinced worked around using "clever" software, which helps not one
whit when reading printouts -- compared to its `+' vs. `-' in
ordinary expressions, because only readers highly experienced with
C itself have become accustomed to spotting the former error as
easily as most readers of C code would spot the latter (assuming
they know the algorithm).

It's tempting to avoid the "math" error by further requiring
more verbosity in the language design.  I believe that, in a
language designed for use by Western scientists -- e.g. any language
one expects to replace Fortran within 50 years -- that would be
a mistake, or at least should be carefully balanced against
the flip side of the problem, e.g., an experienced mathematician
might be more able to spot the bug in `PI+RADIUS' than in
`(plus (pi radius))', having already become accustomed to
lexical-infix notation before ever encountering the new language.

In summary: language designers should try and restrict their use
of narrow lexical distinctions to those areas with which the
expected audience is already very familiar, and, in other areas,
ensure that common typographical errors are most likely to cause
expressions that are immediately discoverable as invalid expressions
in the language.
-- 

"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson    burley@gnu.org




  parent reply	other threads:[~1998-09-26  0:00 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <36068E73.F0398C54@meca.polymtl.ca>
1998-09-22  0:00 ` Fortran or Ada? Gisle S{lensminde
1998-09-22  0:00   ` Jeff Templon
1998-09-22  0:00     ` Rakesh Malhotra
1998-09-22  0:00     ` Larry Kilgallen
1998-09-22  0:00     ` Corey Minyard
1998-09-22  0:00     ` dewarr
1998-09-23  0:00       ` Jeff Templon
1998-09-23  0:00         ` Corey Minyard
1998-09-24  0:00           ` Joel Seidman
1998-09-24  0:00           ` Craig Burley
1998-09-25  0:00             ` dewarr
1998-09-25  0:00               ` Jonathan Guthrie
1998-09-26  0:00               ` Craig Burley [this message]
1998-09-26  0:00                 ` dewarr
1998-09-26  0:00                   ` Craig Burley
1998-09-26  0:00                   ` Robert B. Love 
1998-09-24  0:00         ` Marc A. Criley
1998-09-24  0:00           ` dewarr
1998-09-24  0:00             ` Robert I. Eachus
1998-09-24  0:00               ` William Clodius
1998-09-25  0:00                 ` dewarr
1998-09-25  0:00               ` dewarr
1998-09-25  0:00                 ` Robert I. Eachus
1998-09-25  0:00                   ` dewarr
1998-09-25  0:00             ` jbs
1998-09-26  0:00               ` dewarr
1998-09-28  0:00                 ` jbs
1998-09-29  0:00                   ` Dean F. Sutherland
1998-09-29  0:00                   ` Gautier.DeMontmollin
1998-09-29  0:00                   ` Dean F. Sutherland
1998-09-29  0:00                   ` Dean F. Sutherland
1998-09-29  0:00                   ` William B. Clodius
1998-09-30  0:00                     ` jbs
1998-09-30  0:00                       ` William Clodius
1998-09-30  0:00                       ` dewarr
1998-09-30  0:00                         ` jbs
1998-09-30  0:00                           ` William Clodius
1998-10-03  0:00                       ` Niklas Holsti
1998-10-03  0:00                         ` Toon Moene
1998-10-03  0:00                           ` Niklas Holsti
1998-10-03  0:00                             ` Toon Moene
1998-10-04  0:00                               ` Niklas Holsti
1998-10-05  0:00                                 ` Michel OLAGNON
1998-10-05  0:00                                   ` Ian St. John
1998-10-05  0:00                                     ` Richard D Riehle
1998-10-05  0:00                                       ` dewarr
1998-10-05  0:00                                     ` dewarr
1998-10-05  0:00                                       ` Ian St. John
1998-10-06  0:00                                         ` dewarr
1998-10-06  0:00                                           ` James Giles
1998-10-06  0:00                                             ` Mark A Biggar
1998-10-06  0:00                                               ` James Giles
1998-10-07  0:00                                                 ` dewarr
1998-10-07  0:00                                             ` dewarr
1998-10-06  0:00                                           ` Ian St. John
1998-10-08  0:00                                             ` Offtopic Airport Diversion (Was: Fortran or Ada?) Harold Stevens ** PLEASE SEE SIG **
1998-10-08  0:00                                               ` Ian St. John
1998-10-08  0:00                                             ` Fortran or Ada? Gary L. Scott
1998-10-06  0:00                                           ` Toon Moene
1998-10-06  0:00                                             ` Jonathan Guthrie
1998-10-06  0:00                                     ` Michel OLAGNON
1998-10-07  0:00                                       ` Ian St. John
1998-10-02  0:00                   ` Robert I. Eachus
1998-10-02  0:00                     ` jbs
1998-10-02  0:00                       ` William Clodius
1998-10-03  0:00                         ` jbs
1998-10-03  0:00                           ` Larry Elmore
1998-10-06  0:00                           ` Robert I. Eachus
1998-10-06  0:00                             ` Pat Rogers
1998-10-02  0:00                   ` Geoff Bull
1998-09-24  0:00           ` Jeff Templon
1998-09-25  0:00             ` dewarr
1998-09-25  0:00             ` Dale Stanbrough
1998-09-30  0:00               ` Daniel Barker
1998-09-30  0:00                 ` Lawrence Kirby
1998-10-01  0:00                   ` Aaron Crane
1998-10-02  0:00                 ` Fortran or Ada or gobbledygook? Wes Groleau
1998-10-05  0:00                 ` Fortran or Ada? Terry Devine
     [not found]           ` <6udre0$ha1$1@nnrp1.dejane <6utg60$h6l$1@nnrp1.dejanews.com>
1998-10-01  0:00             ` robin_v
1998-09-23  0:00     ` Frank Ecke
1998-09-23  0:00   ` bglbv
1998-09-23  0:00     ` Robert I. Eachus
1998-09-24  0:00       ` Richard D Riehle
1998-09-23  0:00 Marin David Condic, 561.796.8997, M/S 731-96
1998-09-23  0:00 ` Gisle S{lensminde
1998-09-24  0:00   ` John McCabe
1998-09-24  0:00     ` Gisle S{lensminde
1998-09-24  0:00     ` Dean F. Sutherland
1998-09-24  0:00 ` Samuel T. Harris
  -- strict thread matches above, loose matches on Subject: below --
1998-09-23  0:00 Marin David Condic, 561.796.8997, M/S 731-96
1998-09-24  0:00 Walt Brainerd
1998-09-25  0:00 ` Robert I. Eachus
1998-09-25  0:00 ` dewarr
1998-10-05  0:00 Robert I. Eachus
1998-10-05  0:00 robin
1998-10-05  0:00 Condic, Marin D.
replies disabled

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