comp.lang.ada
 help / color / mirror / Atom feed
* Easily-Read C++?
@ 1994-10-05  3:00 Ken Garlington
  1994-10-05  9:42 ` Pierre Castori
                   ` (5 more replies)
  0 siblings, 6 replies; 43+ messages in thread
From: Ken Garlington @ 1994-10-05  3:00 UTC (permalink / raw)


Robin Rowe <cpp@NETCOM.COM> writes:

<< Here's how I read a piece of C++ code:

    if(!object)                  // "If not object [then]"
    {   cerr<<object.ErrorMsg(); // "output object's error
    }                            //  message,"
    else                         // "else"
    {   object++;                // "increment object."
    }

So what's unnatural about this? Sounds like English to me. >>

Not that I'm a C++ expert, but I have noticed that a lot of C/C++ code looks
like Greek to me. Certainly, that stuff on the right reads like English to me
(is this normal C style to comment every line?) but the stuff on the left I
have to think about a little. On the other hand:

   If Not(object) then
      Text_IO.Put_Line (Error_Message (corresponding_to => object));
   else
      object := object + 1;
   end if;

is easily read by _any_ engineer (never mind software engineer) on my project.
(Of course, I would have to explain what the "not" of a numeric value is,
maybe, but a more meaningful function name is probably a good idea in this
case.) In fact, it looks suspiciously like the English explanation of the C
code. Note that some of these engineers didn't take the math class where "++"
means "add one to the thing before the ++." However, "X = X + 1" is something
they got pretty early on. That colon hanging off the equal sign doesn't seem to
bother them much.

Has anyone tried a study like the following? Take some C++ code from Software
Development, or Embedded Systems Programming, or whatever. Write the Ada 9X
equivalent. Show the 9X code to C++ programmers who have never seen Ada, and
the C++ code to Ada programmers who haven't worked with C recently. Which set
of code would be understood more often?



^ permalink raw reply	[flat|nested] 43+ messages in thread
[parent not found: <3719k1$11gt@watnews1.watson.ibm.com>]
* Re: Easily-Read C++
@ 1994-10-12  3:06 Ken Garlington
  0 siblings, 0 replies; 43+ messages in thread
From: Ken Garlington @ 1994-10-12  3:06 UTC (permalink / raw)


Fred McCall <merlin@ANNWFN.COM> writes:

<< Most of us don't expect people to understand what we write unless they
speak the language, not to mention that only trivial Ada programs are so
easily read and understood. >>

Wrong on both counts. I want people with very little language training or even
software engineering training (if any) to quickly understand the algorithms and
data structures I'm defining. This includes hardware engineers, system test
engineers, IIV&V, SQA, System Safety, etc. I want them to be able to understand
those programs, even if they are 50K source lines of code or more. Ada works
very well for this purpose. Does C++? Sounds like it's a non-issue, since C++
programmers only write for themselves and their fellow programmers.



^ permalink raw reply	[flat|nested] 43+ messages in thread
* Re: Easily-Read C++?
@ 1994-10-14 10:50 Bob Wells #402
  0 siblings, 0 replies; 43+ messages in thread
From: Bob Wells #402 @ 1994-10-14 10:50 UTC (permalink / raw)


Robert Dewar <dewar@CS.NYU.EDU> writes .....

> Subject: Re: Easily-Read C++?
>
> There are to my mind three justifications for comments:
>
> Saying WHY you are doing something, and WHY you did it that way
>
> Saying WHY you did NOT do something, and WHY you did NOT
>
> Describing WHAT the code does, but at a higher level of abstraction
> than the code itself.

G'day Robert,
I totally agree with the above justifications and would also add the
following two:

Describing assumptions about the format or structure of an external
interface, e.g. an incoming message.

-- STAMINA message originator format
-- ORIG/ROLE/HQ

Describing the corresponding meaning for values when they are
defined. For example.

-- The following corresponds to the field RBT in the STORE.QTID section of
-- the PEAQTID file when the TYP field contains a 1 and RBN /= 0.
--
type Rlb_Data is ( Sdd_Coordinates,
                   Plot_Identification,
                   Track_Identification,
                   Sdd_Test_Picture_Display,
                   Track_Id_Or_System_Coordinates,
                   System_Coordinates,
                   Ssr_Code );

Regards,
Bob W. (-:



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

end of thread, other threads:[~1994-11-02  0:46 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-10-05  3:00 Easily-Read C++? Ken Garlington
1994-10-05  9:42 ` Pierre Castori
1994-10-05 13:28   ` Robert Dewar
1994-10-06  2:20     ` Benjamin Ketcham
     [not found]     ` <CxDL8H.KGE@csn.org>
     [not found]       ` <milodCxH2E4.7F4@netcom.com>
     [not found]         ` <CxHJv0.Kw0@csn.org>
     [not found]           ` <DAG.94Oct11080229@bellman.control.lth.se>
     [not found]             ` <37du0k$ir2@gnat.cs.nyu.edu>
1994-10-12  3:19               ` Attractive comments better? R_Tim_Coslet
1994-10-13  1:35               ` Michael Feldman
1994-10-12 17:03           ` Easily-Read C++? John DiCamillo
1994-10-05 14:26 ` Eric S. Sessoms
1994-10-05 17:47 ` Kevin Cline
1994-10-05 22:02   ` Robert Dewar
1994-10-05 22:23     ` Richard Kenner
     [not found]       ` <124377@cup.portal.com>
1994-10-11 18:11         ` David Weller
1994-10-11 18:43         ` Robert Dewar
1994-10-12 13:15           ` Norman H. Cohen
1994-10-12 14:10             ` Robert Firth
1994-10-13 19:33             ` John D. Reading
1994-10-13  0:51         ` Keith Thompson @pulsar
1994-10-05 18:24 ` Magnus Kempe
     [not found] ` <EACHUS.94Oct6101347@spectre.mitre.org>
     [not found]   ` <371a3p$nos@gnat.cs.nyu.edu>
     [not found]     ` <1994Oct7.153254.29848@swlvx2.msd.ray.com>
     [not found]       ` <374uke$8mo@delphi.cs.ucla.edu>
     [not found]         ` <37bno4$ko4@gnat.cs.nyu.edu>
1994-10-11 13:00           ` Robert Firth
1994-10-11 13:44             ` Casper H.S. Dik
1994-10-11 19:03               ` Robert Dewar
1994-10-12 16:38               ` John DiCamillo
1994-10-11 18:52             ` Robert Dewar
1994-10-12 13:49               ` Norman H. Cohen
     [not found]           ` <37eej8$6ie@siberia.gatech.edu>
1994-10-11 18:55             ` Robert Dewar
1994-10-12 13:35               ` John M. Mills
1994-10-12 19:48                 ` Robert Dewar
     [not found]         ` <CxFr5B.K1G@news.otago.ac.nz>
     [not found]           ` <DAG.94Oct10075533@bellman.control.lth.se>
1994-10-11 17:50             ` Norman H. Cohen
     [not found]     ` <373vd2$39n@theopolis.orl.mmc.com>
     [not found]       ` <CxBvq7.GrH@inmet.camb.inmet.com>
     [not found]         ` <37bnic$kj2@gnat.cs.nyu.edu>
1994-10-11 18:02           ` Norman H. Cohen
     [not found] ` <1994Oct7.110309@di.epfl.ch>
     [not found]   ` <DAG.94Oct7204142@bellman.control.lth.se>
     [not found]     ` <1994Oct7.210111.4494@nosc.mil>
     [not found]       ` <374i3o$c87@Starbase.NeoSoft.COM>
1994-10-12 17:37         ` "Tag" (Was: Easily-Read C++? (NOT)) David Emery
     [not found] <3719k1$11gt@watnews1.watson.ibm.com>
     [not found] ` <85C92963672@annwfn.com>
1994-10-11 18:37   ` Easily-Read C++? Norman H. Cohen
1994-10-12 16:54     ` David Emery
1994-10-14 21:13       ` Kevin Cline
1994-10-21 14:38         ` Thomas M. Breuel
1994-10-22  3:10           ` Michael M. Bishop
1994-10-26  0:39             ` -mlc-+Schilling J.
1994-10-27 14:54               ` Bob Duff
1994-10-27 15:35                 ` Richard Kenner
1994-10-27 23:09                 ` Robert Dewar
1994-11-01 21:19                 ` Adam Beneschan
1994-11-02  0:46                   ` Bob Duff
  -- strict thread matches above, loose matches on Subject: below --
1994-10-12  3:06 Easily-Read C++ Ken Garlington
1994-10-14 10:50 Easily-Read C++? Bob Wells #402

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