comp.lang.ada
 help / color / mirror / Atom feed
From: jmartin@oahu.cs.ucla.edu (Jay Martin)
Subject: Re: "Subtract C, add Ada"
Date: 22 Jan 1995 19:09:31 -0800
Date: 1995-01-22T19:09:31-08:00	[thread overview]
Message-ID: <3fv6lb$f4u@oahu.cs.ucla.edu> (raw)
In-Reply-To: 3frsrl$re5@cronkite.seas.gwu.edu

>: The problem is in the language definition, not in the choic of symbols.
>: C is one of the rare language I use to allow having an assignment after 
>: the if statement.  All other languages only allow for a boolean test.

>: I never saw a good reason for allowing this.

Right!

>I think there are three reasons:
> 1. It allows your code to be more compact. Many people think this is
>    a disadvantage, and so it is if the code will be read by comparative
>    novices, but it can improve readability to C experts who are 
>    expecting such tricks.
>
>    NB DONT confuse compactness with poor layout! I find that, for example:
>
>       while ((c = getchar()) == ' ')
>       {
>          /* count spaces */
>       }
>
>    is clearer than the 'expanded' alternative (to *me* :-).

"C expert" does not equal professional programmer.  Just because
someone can read arcane poorly designed code does not mean he is 
competent software engineer.  In fact, I would say that many C
programmers are basically are very incompetent and undeciplined
programmers. No one should write code to please idiots who want
tricks. 

Yuck:
-- We have a function that changes state "getchar()".
-- We have an boolean expression that has a side-effect to c.
-- We have to look twice at the expression to see that we are comparing
   the results of "getchar()" and not "c" (which is just there for
   the ride). 

How about:

loop
  GetChar(C);
  exit when (C /= ' '); 
  ...
end loop;

Sure it has an exit in the loop, it always cracks me up when
programmers who have side-effects galore in their programs start
whining about the "impurity" of having an exit in a loop

> 2. All expressions in C have a value. Conditional tests succeed on 
>    non-zero and fail on zero. Therefore, to maintain orthogonality, 
>    as far as possible, there is no reason to exclude an assignment 
>    expression from a condition.

But we are arguing that languages should not have side-effects in
expressions and thus an assignment should not an expression or sub-
expression or return a value.  So "All expressions in C have a value"
is not gospal it is just another bad language design decision made by
certain incompetent language designers (K&R).  The reason to not to
allow it is that it causes programming errors and terse garbage
code.  
   
> 3. Finally, I suspect, this can simplify the optimisation algorithms 
>    in the compiler.

Ack!  Compiler:
  Warning: Due to that you did not imbed your assignments in boolean
           expression on line 2432, this compiler cannot optimize 
           that statement. Sorry about that.

Again ignorance of compiler optimization abounds.  From what I have
seen the "too macho to trust the compiler" attitude dominates the
industry.  Processors have multiple processing units to schedule and
pipelines filled to minimize stalls.  I just don't see the "optimized
C" computational model as being relevant any more. 

(4)
>Personally, the lack of this sort of compactness in Ada, and things like
>pre- and post-increment/decrement are one of my minor gripes about the
>language. OK, its no big thing to write:

>    P(I) := Q(I);
>    I := I + 1;

>instead of
 
>    *p++ = *q++;

>but I actually *do* find the C representation easier/better etc. (perhaps
>I'm wierd?)

Yup, pretty weird.  Compactness/terseness does not equal better
readibility.   Arrays are higher level than pointers and will be bounds
checked by most adequate languages.  Pointer arithmetic in my opinion
is yet another crap idea from the K&R bozos.

Another C guy:

>BINGO!!!  Readability, like beauty, is in the eye of the beholder.  An
>instructor here made the statement "Pascal is easier to read then C".  I
>don't think so.  In fact I got a D on a midterm because of it.  I was
>the only person in my soph intro CS class using C instead of Pascal, so
>all the code fragments were in Pascal.  To this day, I still can't read
>Pascal's pointer syntax.  Readability is what you are familiar with.
>Both of the C code fragments are very familiar to me and I find *very*
>easy to read (except for the lack of white space in the first one).

Yeah, all things are relative, all is a matter of opinion, all ideas
are of equal merit, etc. (We don't want to upset anyone)

Got a D, good, at least some instructors out there care about
teaching programming / language design.  Wow! so mentally rigid can't
read Pascal's elegant pointer syntax.  Gee, maybe the professor might
just know more than you, maybe when you take a class you should
try to learn something.  Guess you didn't want to learn good
program structure and clean language syntax and semantics. 

>I am tired of novice C users always saying this construct is bad, and
>that construct is bad.  And I don't care to program in C using only
>constructs that a novice would understand at first glance.  Ours is a
>professional environment and certain level of proficiency should be
>expected.  If a high school kid off the street could program like an
>expert, then why are we getting degrees and such?

Again, we have a incorrect correlation here between "professional
programmer" and C hacker.  "Novices" here are equated with
incompetent programmers when they may just be expert software
engineers who fully understand good programming language and software
design.  Why should we want to become proficient in old poorly
designed languages which is hard to learn when we can learn something
that is well designed that we can learn quicker and also have better
productivity in the long run.  I can get no joy from becoming
proficient in crap.  In my opinion, no person should get a
computer science degree with out understanding the flaws of C and
other popular poorly designed languages and systems.    

Heh, (C Idiom == Idiotm)

>Writing ``for (p = head; p; p = p->next) { /* process list */ }''

Ptr := Head;
while (Ptr /= null) loop
  ...
  Ptr := Ptr.Next;
end loop;

(My Ada is rusty, I only program in C++ now)

>Is quite clear to me, but others will probably disagree.  But I find the
>way of reading a file in Ada to quite idiomatic.  At least I was
>taught to enclose the reading from the file in a loop with an exception
>handler w/in the loop.  When the exception would be raised when an attempt
>to read past EOF, then close the file and process what ever your read in.

Actually, depending on exceptions to catch the EOF condition is
bad Ada style as you are depending on an exception for normal program
control.
----------

Okay I was harsh.  But these "C" attitudes of programming are pretty
much the norm in industry and I find this very distressing.  In my
opinion, the Computer Science community must admit their total
failure to teach or even understand or form a consensus about
good software construction and programming language design. 

















  reply	other threads:[~1995-01-23  3:09 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-01-20 10:20 "Subtract C, add Ada" R.A.L Williams
1995-01-20 13:22 ` Renaud HEBERT
1995-01-24  3:35   ` David Moore
1995-01-25  5:38     ` Robert Dewar
1995-01-28 16:35     ` Jules
1995-01-29  8:06       ` Matt Kennel
1995-01-30  5:31       ` Michael Feldman
1995-01-31 22:22         ` David O'Brien
1995-01-24 20:23   ` N. Mellor
1995-01-25  8:50     ` Robb Nebbe
1995-01-25 14:19     ` John Volan
1995-01-26  5:07     ` Samuel Mize
1995-01-26 18:51       ` Mark A Biggar
1995-01-21 15:18 ` Robert Dewar
1995-01-21 21:03 ` David O'Brien
1995-01-23  3:09   ` Jay Martin [this message]
1995-01-23 12:50     ` Andrew McConnell
1995-01-24  0:54     ` Matt Kennel
1995-01-25 17:03       ` Norman H. Cohen
1995-01-26  1:13         ` Dr. Richard Botting
1995-01-26 14:32         ` Anders Juul Munch
1995-01-24  0:17   ` Bob Kitzberger
1995-01-23 20:46 ` Robert Firth
1995-01-24 14:25   ` Samuel Mize
1995-01-25  7:27     ` David O'Brien
1995-01-25 12:14     ` Robert A Duff
1995-01-25  5:57   ` David O'Brien
     [not found]     ` <3g9rf0$71k@Starbase.NeoSoft.COM>
1995-01-28 21:08       ` David O'Brien
1995-01-31 18:07         ` Samuel Mize
1995-02-01 10:23         ` Samuel Mize
1995-01-30  0:24     ` Mark S. Hathaway
1995-01-31  3:30       ` Jay Martin
1995-02-01 13:25         ` Jesper Kaagaard
  -- strict thread matches above, loose matches on Subject: below --
1995-02-10 13:49 R.A.L Williams
     [not found] <3gsr0e$oin@miranda.gmrc.gecm.com>
1995-02-07 16:58 ` Mark S. Hathaway
1995-02-08  7:39   ` Travis C. Porco
1995-02-08 16:07     ` Fred J. McCall
1995-02-08 21:30       ` Garlington KE
1995-01-31  9:34 R.A.L Williams
1995-02-01 16:45 ` Charles H. Sampson
1995-01-23  8:49 R.A.L Williams
1995-01-25 23:18 ` Charles H. Sampson
1995-01-20  9:33 R.A.L Williams
     [not found] <3fgphd$sc3@rational.rational.com>
1995-01-20  5:51 ` RonaldS60
1995-02-07 13:55   ` Robert C. Soong
     [not found] <3fdcoi$chn@miranda.gmrc.gecm.com>
1995-01-20  5:01 ` Samuel Mize
1995-01-20 22:07   ` Garlington KE
1995-01-24  5:02     ` R_Tim_Coslet
     [not found] <3etund$hnr@miranda.gmrc.gecm.com>
1995-01-12  9:56 ` Erik Svensson
1995-01-12 14:44 ` Norman H. Cohen
1995-01-13  1:51 ` David O'Brien
1995-01-13 12:38   ` Laurent Gasser
1995-01-13 20:53     ` John DiCamillo
     [not found]       ` <3f8fnf$c8p@gamma.ois.com>
1995-01-16 11:02         ` Matt Kennel
     [not found]         ` <milodD2IFpG.329@netcom.com>
1995-01-17 21:39           ` R. William Beckwith
     [not found]       ` <3fa11q$sdh@gnat.cs.nyu.edu>
1995-01-16 20:20         ` David Moore
1995-01-14  0:24     ` David O'Brien
1995-01-20  4:43     ` Samuel Mize
1995-01-21 20:28       ` David O'Brien
1995-01-22 21:12         ` Robert Dewar
1995-01-23 18:35         ` Norman H. Cohen
1995-01-23 19:18         ` John Cosby - The Coz
1995-01-24 14:11         ` Samuel Mize
1995-01-14 10:37   ` Keith Thompson
     [not found]     ` <3fcjgt$b0v@cronkite.seas.gwu.edu>
1995-01-16 18:47       ` Robert Dewar
     [not found]   ` <D2It0r.4rp@inmet.camb.inmet.com>
1995-01-17 14:11     ` Norman H. Cohen
1994-12-30 16:06 Mitch Gart
1995-01-03 19:04 ` whiting_ms@corning.com (Matt Whiting)
1995-01-05  4:31   ` Michael Feldman
1995-01-04 21:40 ` Fred McCall
1995-01-05  4:30   ` Richard Pattis
1995-01-05 16:07   ` Kevin Weise
1995-01-06 13:06   ` Jahn Rentmeister
1995-01-06 16:47     ` Laurent Gasser
1995-01-06 17:29       ` David Weller
1995-01-06 17:30         ` David Weller
1995-01-10 18:28       ` Bob Kitzberger
1995-01-06 23:36   ` Kenneth Almquist
1995-01-04 22:45 ` Jay M. Martin
1995-01-05  4:37   ` Michael Feldman
1995-01-05 18:08     ` Jay Martin
1995-01-05 23:56       ` Robert Dewar
1995-01-08  8:04         ` Jay Martin
1995-01-06  0:07       ` Michael M. Bishop
1995-01-10 21:30         ` Jay Martin
replies disabled

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