comp.lang.ada
 help / color / mirror / Atom feed
* Re: problems/risks due to programming language, stories requested
@ 1990-02-28 18:57 Paul Snively
  1990-03-02 19:19 ` David F. Carlson
  0 siblings, 1 reply; 23+ messages in thread
From: Paul Snively @ 1990-02-28 18:57 UTC (permalink / raw)


In article <BILL.90Feb27143004@hcx2.ssd.harris.com> bill@ssd.harris.com 
(Bill Leonard) writes:
> In article <9790@medusa.cs.purdue.edu> gb@cs.purdue.EDU (Gerald 
Baumgartner) writes:
>            Again it looks like this bug wouldn't have occurred in another
>            programming language.
> 
> I can't resist saying that this last statement seems to me to be utter
> nonsense.  What programming language (read, compiler) can read the
> programmer's mind and tell what he meant?  The use of the "break" 
statement
> was a logic error (actually, it sounds like it was a lack of knowledge of
> the language, since "break" does not apply to "if").  I can't imagine a
> programming language that could discern this type of error.  [If I use
> WHILE instead of IF, for instance, I can expect some things to work and
> some not.  Yet I seriously doubt any compiler could possibly detect this
> error.]
> 
> I certainly think programmers often choose an inappropriate language, 
but I
> shy away from anecdotal stories like these because they seem (to me) to
> spread a lot of misinformation.  Unless you implement a project in 
multiple
> languages, it is nothing more than a guess to say what would have 
happened
> if the project had been implemented in some other language.  Perhaps you
> would have discovered an even more serious flaw in that language, or you
> might simply find it was no better or worse than the one you chose, just
> different.
> 
> Most of the stories I have heard along these lines all struck me as 
missing
> the point: how well was the program tested?  Were there code reviews?
> Design reviews?  All of these techniques are proven to reduce errors.  
Most
> of the errors in these stories (e.g., the infamous dot-versus-comma one)
> should have been found with even rudimentary testing.
> 
> Use of an inappropriate language is no excuse for abandoning other 
techniques
> of good software engineering.

I don't think that anyone's claiming that it is an excuse; I believe the 
point was that some languages applied to some tasks lend themselves to 
error more than another language applied to the same task.  If you wish to 
interpret the above story as a rather pointed jab at the C programming 
language, and object to C being treated that way, that's fine, but please 
just say so.

For what it's worth, my personal opinion is that C lends itself to 
precisely the kinds of errors noted above--when does break work and when 
doesn't it, and why in God's name do you need it in switch statements in 
the first place, etc.  I believe that it's C's historical looseness that 
is simultaneously its greatest weakness, when it leads to errors like 
this, and its greatest strength--C doesn't restrict you; C is mean and 
lean; C is close to the hardware; real programmers use C; even, God help 
us, C is the only language you need!  We all know C programmers whose 
machismo is thus huffed and puffed up (another of my personal opinions is 
that the per capita arrogance of C programmers far outweighs the per 
capita arrogance of any other language-aficionado group).

Now to get back to the important point: what language would have been 
better for the task in question?

Well, I hate to say it, but it's extremely unlikely that such an error 
would have been made in Pascal, since Pascal doesn't require you to 
explicitly break from case...of constructs.

Before the flames start, let me just add: no, I don't necessarily prefer Pascal over C for all tasks.  I generally attempt to choose the right tool for the job, rather than falling into the "when all you have is a hammer, everything looks like a nail" trap.

Standard Disclaimer.

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: problems/risks due to programming language
@ 1990-02-24 19:39 Erland Sommarskog
  0 siblings, 0 replies; 23+ messages in thread
From: Erland Sommarskog @ 1990-02-24 19:39 UTC (permalink / raw)


Scott MacHaffie (machaffi@fred.cs.washington.edu.cs.washington.edu) writes:
)Bill Wolfe (billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu) writes:
))   the NEXT case.  In other words, C requires the programmer to use a
))   dangerous construct on a routine basis.
)
)(the dangerous construct is the "break" statement)
)But if "break" were renamed "end case" then there wouldn't be any problem?
)
))   code associated with the else part.  Thus, we have an inconsistency
))   in C's design: with one flow-of-control construct (the switch), it is
))   necessary to use a dangerous GOTO to achieve normal processing, whereas
)
)No, it is necessary to use a statement to indicate that the current case
)statement is finished...like an "end case" or the next "when =) " in ADA.

I don't speak C, so I might have missunderstood something, but I'm
under the impression that you may exclude the "break" statement
achieving the effect that you execute the code for the next case too.
Sometimes possibly a nifty feature, but it seems to me that is a good
source of errors. Whether it's called "break" or "end case" has no
importance. You may inadvertantly forget it in both cases.

)I don't use LINT. I use compilers that check certain things I want checked,
)like "no prototypes in scope".  LINT does not catch the kinds of mistakes
)that I make.  How many ADA programmers do you know of use LINT?

Ada programmers don't use lint, they don't have to.

From another article by Scott MacHaffie:
)Good programmers understand the language they are using -- good programmers
)are literate. No language can eliminate errors. Good software engineering
)practices should be used to (try to) catch language-specific errors.

And good languages should have as few unnecessary traps as possible
to help the software engineer spend his efforts on essentials.
-- 
Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se

^ permalink raw reply	[flat|nested] 23+ messages in thread
[parent not found: <10811@june.cs.washington.edu% <8126@hubcap.clemson.edu% <10838@june.cs.washington.edu>]
* Re: problems/risks due to programming language
@ 1990-02-23  6:46 Scott MacHaffie
  0 siblings, 0 replies; 23+ messages in thread
From: Scott MacHaffie @ 1990-02-23  6:46 UTC (permalink / raw)


In article <8126@hubcap.clemson.edu% billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu writes:
%From machaffi@fred.cs.washington.edu (Scott MacHaffie):
%% No, it is necessary to use a statement to indicate that the current case
%% statement is finished...like an "end case" or the next "when =% " in ADA.
%
%   Such a statement already exists: either the next "case Value:", or 
%   the } which ends the switch.  Why is it necessary to use a "break"?

example:
	switch (x) { /* x is a character, for example */
		case '0': case '1': ... case '9':
			print_digit(x);
			break;
		case 'a': ... case 'z':
			print_lowercase(x);
			break;
	}
The semantics of a C switch/case statement are different than the semantics
of an ada case/when.

%   The problem cannot simply be defined out of existence by saying,
%   in essence, that good programmers don't make mistakes.  All human
%   programmers make mistakes, and a well-designed language will help
%   to minimize this particular tendency.  In this case, C does not. 

Good programmers understand the language they are using -- good programmers
are literate. No language can eliminate errors. Good software engineering
practices should be used to (try to) catch language-specific errors.

%%%   This is certainly true; Brooks and others have noted that the good
%%%   software engineering practices which are routinely introduced in
%%%   conjunction with the Ada language are responsible for more of the 
%%%   resulting improvements than the fact that the Ada language was
%% 
%% Well, these practices are certainly NOT being introduced in the 
%% universities (at least not here).
%
%   In that case, I strongly suggest that you immediately bring 
%   this fact to the attention of the software engineering faculty 
%   at washington.edu.  At other universities (e.g., Clemson), Ada
%   *is* introduced in conjunction with software engineering.

Software engineering faculty?  I wish. None of the undergraduate classes
here touch software engineering, and I think at most one of the graduate
classes does. Anyone who wants to be a software engineer here has to
pick it up from other sources.

			Scott MacHaffie

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: problems/risks due to programming language, stories requested
@ 1990-02-21 16:49 Richard A Hammond
  1990-02-21 20:15 ` problems/risks due to programming language William Thomas Wolfe, 2847 
  0 siblings, 1 reply; 23+ messages in thread
From: Richard A Hammond @ 1990-02-21 16:49 UTC (permalink / raw)


In article <9790@medusa.cs.purdue.edu> gb@cs.purdue.EDU (Gerald Baumgartner) writes:

>For a research project I am collecting information about the risk of
>choosing the wrong programming language. In particular I am looking
>for problems that could have been avoided if another (a better)
>programming language would have been used.

>I know of these three such stories:
	...
>     3. The AT&T breakdown a month ago was caused by a break statement
>	in C. See the following mail (multiple forwarding headers deleted):

>| | This is the bug that cause the AT&T breakdown
>| | the other day (no, it wasn't an MCI virus):
>| | 
>| | In the switching software (written in C), there was a long
>| | "do . . . while" construct, which contained
>| |    a "switch" statement, which contained 
>| |       an "if" clause, which contained a
>| |          "break," which was intended for
>| |       the "if" clause, but instead broke from
>| |    the "switch" statement.
>| | 
>
>	Again it looks like this bug wouldn't have occurred in another
>	programming language.

What other programming language?  Only one without any GOTO or restricted
GOTO (e.g. exit, break, ...).  This leaves out Ada!!!!!!

Similar bug in Ada: 	(Cut down for posting, but gives the flavor)

procedure test is
        MAX : constant := 10; 
        type t is array(positive range 1 .. MAX) of boolean; 
        NEW_ITEMS : t; 
 
    begin 
        for N in 1 .. MAX loop 
	    case ...
	    when ... =>
                if NEW_ITEMS(N) = FALSE then 
			-- some other useful work gets done here
                        exit; 			-- exits loop, not if!
                end if; 
	    when ... =>
	    end case;
        end loop; 
    end test;

So, in the AT&T case using Ada we would have exited both the switch and the
loop rather than just the switch.  Hardly an improvement!

More generally, I find it distressing that the advocates of Ada are
failing to distinguish between language independent features and language
dependent features in assigning credit for software improvements.

In my limited experience the cases where Ada is introduced into a
programming environment also introduce lots of other good software
engineering practices.  For example, lots of people I know who
program in C don't use LINT.   I view it as a deficiency of management
and not of the language that they don't use available tools.

I bring this up because Ada isn't the last language ever to be designed
and we should be willing to learn what could be used in future languages.

Rich Hammond

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

end of thread, other threads:[~1990-03-03  2:10 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5432@crdgw1.crd.ge.com) <8103@hubcap.clemson.edu) <10811@june.cs.washington.edu) <806@enea.se>
1990-02-26 18:48 ` problems/risks due to programming language What`s in a name?
1990-02-26 22:02   ` Karl Heuer
1990-03-02 10:57   ` Erland Sommarskog
1990-02-28 18:57 problems/risks due to programming language, stories requested Paul Snively
1990-03-02 19:19 ` David F. Carlson
1990-03-03  2:10   ` problems/risks due to programming language Karl Heuer
  -- strict thread matches above, loose matches on Subject: below --
1990-02-24 19:39 Erland Sommarskog
     [not found] <10811@june.cs.washington.edu% <8126@hubcap.clemson.edu% <10838@june.cs.washington.edu>
1990-02-23 18:55 ` B. S. Oplinger
1990-02-23  6:46 Scott MacHaffie
1990-02-21 16:49 problems/risks due to programming language, stories requested Richard A Hammond
1990-02-21 20:15 ` problems/risks due to programming language William Thomas Wolfe, 2847 
1990-02-21 22:49   ` Richard A Hammond
1990-02-21 23:14   ` John F Nixon
1990-02-22  5:39   ` Scott MacHaffie
1990-02-22 20:13     ` William Thomas Wolfe, 2847 
1990-02-23 17:32       ` Richard A Hammond
1990-02-25 20:23         ` David Kassover
1990-02-22 20:48     ` Jeff Lawhorn
1990-02-23  2:00     ` Douglas Miller
1990-02-22 16:05       ` Dan L. Pierson
1990-02-22 20:28         ` David Kassover
1990-02-24 19:52         ` Erland Sommarskog
1990-02-23 17:45       ` Mike Harrison
1990-02-27  2:02         ` Douglas Miller
1990-02-22 18:28   ` Mike Percy
1990-02-23  2:09   ` Douglas Miller

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