home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / software / 4941 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  4.0 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!darwin.sura.net!uvaarpa!concert!borg!news_server!martinc
  2. From: martinc@hatteras.cs.unc.edu (Charles R. Martin)
  3. Newsgroups: comp.software-eng
  4. Subject: Re: C code Layout
  5. Message-ID: <MARTINC.92Dec14115542@hatteras.cs.unc.edu>
  6. Date: 14 Dec 92 16:55:42 GMT
  7. References: <1992Dec12.122453.8582@seq.uncwil.edu>
  8.     <1992Dec12.200619.29602@fcom.cc.utah.edu>
  9.     <1992Dec14.074411@eklektix.com>
  10. Sender: news@cs.unc.edu
  11. Organization: UNC Department of Computer Science
  12. Lines: 65
  13. In-reply-to: rcd@raven.eklektix.com's message of 14 Dec 92 07:44:11 GMT
  14.  
  15. In article <1992Dec14.074411@eklektix.com> rcd@raven.eklektix.com (Dick Dunn) writes:
  16.  
  17.  
  18.    >If you believe that K&R is "about right", then we will never
  19.    >come to agreement on what the right amount of comments is.
  20.  
  21.    .... the style of code and the amount/style of comments
  22.    do not differ significantly from what you'd have found in the UNIX source
  23.    10-15 years ago.  In other words, Ritchie and Kernighan...and Thompson and
  24.    others...wrote and write C in a style not too different from what you see
  25.    in K&R.
  26.  
  27.    Next, step back and look at where UNIX has gone.  That code has been read
  28.    and understood by tens of thousands of people, and has been successfully
  29.    modified over and over again for many years, often by people with almost no
  30.    training or aptitude.  Like it or not, there is massive evidence that the
  31.    style DOES work, IS understandable, and IS maintainable.  It's *not* the
  32.    only workable style!  But it works.
  33.  
  34. Well, I appreciate your kind comments [that I've deleted] but I disagree
  35. with you on this one.  First of all "maintainable" is not a boolean.
  36. I've been doing low-level UNIX hacking for a long while now, often
  37. working from the BSD and occassionally AT&T sources.  While I agree that
  38. it is *possible* to maintain the system from the KR&T level of
  39. commenting, it is not -- in my experience -- very economic.  I don't
  40. necessarily maintain that something like
  41.  
  42.     /* copy str a to str b using pointer arithmetic */
  43.     while( a++ = b++) 
  44.         ;
  45.  
  46. is the level of detail comments need, but on the other hand older
  47. research UNIX systems are just chock full of things like
  48. multiple-indirection- and-shift expressions, complicated nested ?:, and
  49. the like that just cry out for explanatory comments.  In the original
  50. KR&T environment, where it was three or four guys bootlegging a system,
  51. this was all right.  In a university setting, where labor is cheap and
  52. expertice is its own reward, it is survivable.  If someone needs to
  53. spend a week understanding the source for "script", well, it only cost
  54. you $250.  Things are very different when a week costs $2000.
  55.  
  56.    If you want to understand the value and effect of comments, and of various
  57.    commenting styles, I submit that you had better start with the understand-
  58.    ing that K&R style DOES work.  If you've got the idea stuck in your head
  59.    that it can't possibly be any good, then you'd better start by trying to
  60.    figure out why it works.  As I said, reality is trump.
  61.  
  62. Ah, but what is "reality"?  (What is Truth, he said, washing his hands.)
  63. It is a fact that UNIX has been extended and maintained in the past
  64. without what I consider a useful level of comments; it is also a fact
  65. that every commercial version of UNIX I've seen has at least a factor of
  66. five more comments that the old AT&T sources.
  67.  
  68. Now, another ongoing thread in this group is about "literate
  69. programming"; there appears to be a developing body of experience that
  70. suggests literate programming is at least as productive (and maybe
  71. more), and results in higher quality code that appers to be reasonably
  72. maintainable.   This appears to be a direct contradiction of the notions
  73. that herbst et al have expressed.
  74. --
  75.         Charles R. Martin/(Charlie)/martinc@cs.unc.edu
  76.      Dept. of Computer Science/CB #3175 UNC-CH/Chapel Hill, NC 27599-3175
  77.         3611 University Dr #13M/Durham, NC 27707/(919) 419 1754
  78.      "Oh God, please help me be civil in tongue, pure in thought, and able
  79.       to resist the temptation to laugh uncontrollably.  Amen." -- Rob T
  80.