comp.lang.ada
 help / color / mirror / Atom feed
* Re: Is there a language that Dijkstra liked? (was: Re: Software landmines (loops))
@ 1998-10-28  0:00 John Woodruff
  1998-10-28  0:00 ` Pat Rogers
  0 siblings, 1 reply; 56+ messages in thread
From: John Woodruff @ 1998-10-28  0:00 UTC (permalink / raw)


>>>>> "Pat" == Pat Rogers <progers@NOclasswideSPAM.com> writes:
In article <712r19$rs5$1@supernews.com> "Pat Rogers" <progers@NOclasswideSPAM.com> writes:

    > Ehud Lamm wrote in message ...
    >> On Mon, 26 Oct 1998 dennison@telepath.com wrote:

    > <good points all>

    >> Still - Remember you can achieve all the run time checking
    > functionality
    >> in any language. It is just that in some languages you have to
    >> code
    > it
    >> explicitly. But you want your code to be of quallity - you just
    > have to do
    >> it.


    > Explicitly coded checks come at a price, though, that
    > language-defined checks may be able to avoid.  ......

Another consideration occurs when the programmer offers to code his
(her) own checks, in defense against the kind of errors that Ada's
checking prevents:

    > ...... In Ada, the fact
    > that the check is defined by the language means that we don't
    > explicitly write the it ourselves, and the optimizer then has
    > freedom to help us with performance.  Ironic, isn't it?

The programmer is setting out to write additional code, and that code
itself is susceptible to some defects.  Shouldn't we worry that these
defects injected into the *checking* code might lower the quality of the
product?




^ permalink raw reply	[flat|nested] 56+ messages in thread
* Re: Is there a language that Dijkstra liked? (was: Re: Software landmines (loops))
@ 1998-10-14  0:00 R. Kerr
  1998-10-14  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 56+ messages in thread
From: R. Kerr @ 1998-10-14  0:00 UTC (permalink / raw)


Rick Smith (ricksmith@aiservices.com) wrote:

> Of the comments attributed to Dijkstra, I have never heard a comment
> that was favorable toward any language! Is there a language that Dijkstra
> liked?

> Of which features of any language did Dijkstra make favorable comments?

> Based upon his comments, what languages might Dijkstra like today?

> Would Dijkstra have favorable comments for the OO languages, in
> particular?

I suppose Dijkstra, as one of the holy triumvirate who wrote the
seminal "Structured Programming" in 1972, did not find too abhorrent
the language used by co-author Ole-Johan Dahl in his chapter
"Hierarchical Program Structures".  That language was SIMULA, the most
influential ancestor of all OO languages.

Cheers....Ron

------------------------------------------------------------------------
 Ron Kerr, Computing Service,  Newcastle University, NE1 7RU, England.
 Tel. +44 191 222 8187  Fax. +44 191 222 8765  E-mail r.kerr@ncl.ac.uk
------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 56+ messages in thread
* Re: Software landmines (was: Why C++ is successful)
@ 1998-08-19  0:00 adam
  1998-08-19  0:00 ` Dan Higdon
  1998-10-21  0:00 ` Van Snyder
  0 siblings, 2 replies; 56+ messages in thread
From: adam @ 1998-08-19  0:00 UTC (permalink / raw)


In article <6renh8$ga7$1@nnrp1.dejanews.com>,
  ell@access.digex.net wrote:

> A 'return', at least in C/C++/VB, returns you to the place the current
> procedure was called from.  'goto' control flow can be endlessly channeled
> here and there and never has to return to where the initial linear control
> flow was originally diverted.  That seems to be a huge advantage of 'return'
> over 'goto'.

No, to me this seems to be a huge advantage of "return" over "using too many
goto's in your code that go every which way so that your code ends up looking
like spaghetti."  No one is supporting the idea of using that many goto's,
the way programmers used to.  Those who think goto's are OK think they should
be limited to certain specific situations, and your objection really doesn't
apply when goto's are used in that sort of careful, disciplined fashion.  Of
course, "goto" can be dangerous in the hands of an inexperienced programmer;
but so, for that matter, can every other construct of every language.

In the 22 years or so since programmers have started treating "goto" as an
evil, I've seen some pretty strange arguments purporting to explain *why*
goto's were bad.  The most bizarre one I've seen argued that if your code is
structured as follows:

         Transformation-1;  goto L;  Transformation-2;  L: ....

where Transformation-1 and Transformation-2 are sequences of statements or
something else that transform your current program state from one thing to
another, then the presence of "goto" in effect means that your code contains
the inverse function of Transformation-2, which cancels the effect of
Transformation-2.  The author offered this as an explanation why "goto" makes
code harder to understand.  I don't remember exactly where I read this, but it
was in one of the ACM publications.

Of course, this is nonsense.  There are good reasons why a researcher might
want to think of a "program" as a sequence of mathematical transformations on
the program state, but an ordinary programmer trying to write correct code,
or to read or maintain someone else's code, isn't going to think about things
that way.  That's why I'm skeptical about most of the arguments I see about
why GOTO IS EVIL.  There often seems to be an implicit assumption that
mathematical purity, or an aesthetically beautiful program structure, or
something similar, equals readability, but that isn't the case.  So when I
see statements like "'goto' control flow can be endlessly channeled here and
there and never has to return to where the initial linear control flow was
originally diverted", my reaction is, "So what?"  This argument contains no
explanation *why* this makes programs harder to work with.

So, personally, I think arguments against "goto" (or against any other
construction) should demonstrate things from the programmer's point of view.
That is, how does this EVIL NASTY construct actually make it harder for a
programmer to understand what's going on, or make it easier for a programmer
to miss something and write incorrect code?  If the argument doesn't address
the issue from that angle, it's worthless, IMHO.

Now, here are a couple arguments on the other side:

(1) Say you want to avoid the EVIL NASTY "goto" by putting the code into a
subroutine and using "return".	Well, you have to give the subroutine a name.
In place of the nested "if" causing the problem, you'll have a call to this
subroutine.  Now, when a programmer looks through the main line of code,
she'll see a call to this subroutine, and she'll have to know what it does. 
Can you give the subroutine a name that will make it obvious to the
maintenance programmer what's going on?

Sometimes you can.  But if all you're doing is extracting some code and
sticking it in a subroutine, most of the time you can't give it a good
descriptive name, since it reflects just a random sequence of statements and
not a concept that can be easily compartmentalized.  So in this case, IMHO
doing this is worse than using "goto", since it makes the program less clear.
 Of course, you can probably figure out a way to redesign the code to make it
clear, and your code will be more readable since it has smaller, more compact
subroutines that perform a well-defined purpose.  But this just illustrates
the importance of good design in general; a programmer who simply says
"RETURN is a lot better than GOTO" and moves code around just to avoid the
GOTO is unlikely to end up with a more readable and maintainable program.

(2) (This one is about "continue", since Charles Hixson later argued that this
was also superior to "goto" for the same reasons.)  If you have a loop that
looks like:

     while (blah-blah) {
          some-if-statements...
          some-more-if-statements...

          xxx;
          yyy;
          zzz;
     }

someone reading the program might assume that xxx, yyy, and zzz are always
going to happen before the loop repeats.  So if there's something new that
needs to be done during every loop iteration, it looks like you can just add
it to the end of the loop, after zzz.  If there's a "continue" statement
somewhere above that, this assumption is incorrect and your modification may
well be wrong.	If you replace the "continue" with a "goto", at least there
will be a label somewhere toward the bottom of the loop, alerting you to the
fact that you will have to decide whether to put the new code before or after
the label, or look for the place where this label is goto'ed.  In fact, this
is exactly why I stopped using "continue" when I was a C programmer.  (I
didn't replace them with goto's, I used Boolean flags instead.)

Now all of this may be a matter of how each individual programmer tends to
think when they look at programs.  The point is that, based on my experience,
arguments about "returning to where the linear control flow was diverted" and
"restricted compass" don't make a whole lot of sense in the real world.  GOTO
can be used in ways that enhance readability or in ways that impair it, and
so can every other feature of every language.

				-- Adam

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~1998-10-29  0:00 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-28  0:00 Is there a language that Dijkstra liked? (was: Re: Software landmines (loops)) John Woodruff
1998-10-28  0:00 ` Pat Rogers
1998-10-29  0:00   ` Ehud Lamm
  -- strict thread matches above, loose matches on Subject: below --
1998-10-14  0:00 R. Kerr
1998-10-14  0:00 ` Matthew Heaney
1998-10-14  0:00   ` R. Kerr
1998-08-19  0:00 Software landmines (was: Why C++ is successful) adam
1998-08-19  0:00 ` Dan Higdon
1998-08-20  0:00   ` adam
1998-08-20  0:00     ` Software landmines (loops) Nick Leaton
1998-08-30  0:00       ` Matthew Heaney
1998-08-30  0:00         ` Robert Martin
1998-08-31  0:00           ` Andrew Hussey
1998-09-01  0:00             ` Gerry Quinn
1998-09-01  0:00               ` Robert Martin
1998-09-02  0:00                 ` mfinney
1998-09-02  0:00                   ` Robert Martin
1998-09-02  0:00                     ` Ell
1998-09-02  0:00                       ` Robert Martin
1998-09-02  0:00                         ` Ell
1998-09-02  0:00                           ` Robert Martin
1998-09-02  0:00                             ` Ell
1998-09-02  0:00                               ` Robert Martin
1998-09-03  0:00                                 ` Joe Gwinn
1998-09-06  0:00                                   ` Charles Hixson
1998-09-08  0:00                                     ` adam
1998-09-09  0:00                                       ` Gerry Quinn
     [not found]                                         ` <gio+van+no+ni+8-1609980034390001@dialup26.tlh.talstar.com>
1998-09-16  0:00                                           ` Biju Thomas
1998-09-16  0:00                                             ` Is there a language that Dijkstra liked? (was: Re: Software landmines (loops)) Rick Smith
1998-09-17  0:00                                               ` Markus Kuhn
1998-09-17  0:00                                                 ` Pat Rogers
1998-09-17  0:00                                                   ` dewarr
1998-09-17  0:00                                                   ` David C. Hoos, Sr.
1998-09-17  0:00                                                 ` dewarr
1998-09-17  0:00                                                   ` Biju Thomas
1998-09-18  0:00                                                     ` dewarr
1998-09-18  0:00                                                       ` Markus Kuhn
1998-10-09  0:00                                                   ` Matthew Heaney
1998-10-09  0:00                                                     ` Pat Rogers
1998-10-09  0:00                                                     ` Jay Martin
1998-10-09  0:00                                                       ` Pat Rogers
1998-10-10  0:00                                                       ` Dave Wood
1998-10-13  0:00                                                       ` last.first
1998-10-23  0:00                                                         ` Gautier.DeMontmollin
1998-10-23  0:00                                                         ` Brian Mueller
1998-10-23  0:00                                                           ` midlamD
1998-10-23  0:00                                                             ` Ell
1998-10-23  0:00                                                           ` Arun Mangalam
1998-10-23  0:00                                                             ` DPH
1998-10-24  0:00                                                               ` Michael Stark
1998-10-23  0:00                                                           ` Ell
1998-10-24  0:00                                                           ` Dave Wood
1998-10-24  0:00                                                           ` Dale Stanbrough
1998-10-24  0:00                                                           ` Ehud Lamm
1998-10-24  0:00                                                           ` Dave Wood
1998-10-24  0:00                                                             ` Tucker Taft
1998-10-26  0:00                                                           ` Bill Ghrist
1998-10-27  0:00                                                             ` Ell
1998-10-27  0:00                                                               ` dewarr
1998-10-11  0:00                                                     ` Bertrand Meyer
1998-10-12  0:00                                                       ` Rod Chapman
1998-10-12  0:00                                                       ` Pat Rogers
1998-10-13  0:00                                                       ` Robert I. Eachus
1998-09-18  0:00                                                 ` bengt
1998-10-09  0:00                             ` Gautier.DeMontmollin
1998-10-21  0:00 ` Van Snyder
1998-10-22  0:00   ` biocyn
1998-10-26  0:00     ` Ehud Lamm
1998-10-26  0:00       ` Tucker Taft
1998-10-26  0:00         ` dennison
1998-10-26  0:00           ` Ehud Lamm
1998-10-26  0:00             ` Pat Rogers
1998-10-27  0:00             ` dennison
1998-10-27  0:00           ` Dave Wood
1998-10-28  0:00             ` norm
1998-10-27  0:00           ` bill
1998-10-27  0:00       ` dewarr
1998-10-27  0:00         ` Ehud Lamm

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