comp.lang.ada
 help / color / mirror / Atom feed
From: jbaker@gmu90x.gmu.edu (jbaker)
Subject: Re: problems/risks due to programming language, stories requested
Date: 6 Mar 90 10:11:05 GMT	[thread overview]
Message-ID: <2596@gmu90x.gmu.edu> (raw)
In-Reply-To: 8218@hubcap.clemson.edu

In article <8218@hubcap.clemson.edu> Bill Wolf writes:
>From dave@micropen (David F. Carlson):
>>> 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.
>> 
>> A multi-case switch is very handy in many situations to reduce identical
>> treatments for similar cases.  

But the real usefulness of requiring break in a switch statement is for
SIMILAR treatments of similar cases, for example you may require a
few assignments in one case before a more complicated computation which
must be performed for several of the cases.

This could be done in other languages using conditionals or multiple case
statements, but it's not quite as nice.

Bill Wolf writes:
>   So is a multi-alternative case, as provided by Ada:
>
>      case Foo is
>         when 1 | 3 | 5 =>
>            statement1;
>         when 2 | 4 | 6 =>
>            statement2;
>         when others =>
>            statement3;
>      end case;
>
>   The difference is that Ada takes care of exiting the case statement
>   for you, whereas C requires (unsafely) that you use a break to avoid 
>   being sucked into the code associated with subsequent cases.  
>
But this is just one example of the design philosophy of C: flexibility;
if the machine will let you do it (or naturally WANTS to do it), let the
programmer do it the same way.  Other examples of such flexibilty are the
lack of type-checking, as well as allowing assignments just about anywhere.

Some languages, such as Pascal, have more limitations (or less extentions)
in their constructs.  This usually is perfectly adequate, but for someone
who writes code while thinking about how the machine will execute that 
code, as I do, flexibility can be useful; a small amount of speed-up, and more
compact code can be the result. 

However, this capability has a trade-off; flexibility for follow-ability.
Humans do not think like computers.  We can not precisely process syntax.
When code becomes too involved, it can become very difficult to follow for
even the author.  What could be a straight-foward program may now be a twisted
mess.  It becomes easy to overlook bugs that would be obvious in other
languages.  This is why C programmers rely heavily on a debugger.
What one calls "safety" in a language, then, is just how well humans can
follow a construct, without regard for its usefulness.  C is not "safe,"
but while being quite simple and relatively low-level, it contains many
flexible constucts.

Sometimes, though, flexibility is present in other languages in a more
"safe" fashion.  For example, type conversion is available in Modula-2
IF it is explicitly done in the code.  In order to use a pointer as a
integer, for example, one might use: INTEGER(ch^).  This flags the compiler
that "we meant to do that" and warns humans that something tricky is going on.

But C can be delightful to use, if you are very careful to write clear code.


John Baker
jbaker@gmuvax.gmu.edu

Now about deciphering all those }++|#{ symbols....

  reply	other threads:[~1990-03-06 10:11 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-02-20 22:28 problems/risks due to programming language, stories requested Gerald Baumgartner
1990-02-21 16:49 ` 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
1990-02-22  0:25   ` problems/risks due to programming language, stories requested David Kassover
1990-02-22  3:42     ` Richard A Hammond
1990-02-22 16:08       ` David Kassover
1990-02-22 16:21       ` David Kassover
1990-02-23 18:11 ` Thomas Vachuska
1990-02-24  0:13 ` Mark Brader
1990-02-27 19:30 ` Bill Leonard
1990-02-28 18:57   ` Paul Snively
1990-02-28 21:35     ` Jason Coughlin
1990-03-01 19:00       ` Barry Margolin
1990-03-02 13:31         ` Richard A Hammond
1990-03-02 19:26           ` William Thomas Wolfe, 2847 
1990-03-02 22:19             ` Richard A Hammond
1990-03-06 21:54               ` John Boone
1990-03-03 20:18             ` Charles E Eaker
1990-03-03 21:11               ` Invalid analogy William Thomas Wolfe, 2847 
1990-03-03 23:26                 ` I Wish
1990-03-05 19:51                 ` John F Nixon
1990-03-09 17:20                 ` Tony Sanders
1990-03-01 15:33     ` problems/risks due to programming language, stories requested Jeff Dalton
1990-03-01 21:42       ` Chuck Lins
1990-03-02 19:19     ` David F. Carlson
1990-03-02 22:15       ` William Thomas Wolfe, 2847 
1990-03-06 10:11         ` jbaker [this message]
1990-03-08 15:19           ` Lou Steinberg
1990-03-08 21:44             ` Gianfranco Ciardo
1990-03-09 16:18               ` David Kassover
1990-03-09 16:55               ` Erann Gat
1990-03-10 17:50               ` Andrew P. Mullhaupt
1990-03-12  4:06                 ` Peter da Silva
1990-03-12 16:58                 ` Jeff Clark
1990-03-12 20:20                 ` Proposal comp.lang.jihad (was Re: problems/risks due to blah etc.) What`s in a name?
1990-03-09 20:13         ` problems/risks due to programming language, stories requested Tony Sanders
1990-03-13 22:11           ` Erland Sommarskog
1990-03-19  1:01           ` Ada vs C, objectivity requested Lucio de Re
1990-03-26 20:37             ` Karl Heuer
1990-03-15 15:31         ` problems/risks due to programming language, stories requested jaws
1990-03-02 23:27       ` Jim Giles
1990-03-03  2:23         ` Vincent Manis
1990-03-03  2:10       ` problems/risks due to programming language Karl Heuer
1990-03-02 23:01     ` problems/risks due to programming language, stories requested William J. Bouma
1990-03-14  4:46     ` Lindsay Groves
  -- strict thread matches above, loose matches on Subject: below --
1990-03-16  9:38 vanavermaet
replies disabled

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