home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / forth / 3749 < prev    next >
Encoding:
Internet Message Format  |  1993-01-03  |  4.3 KB

  1. Path: sparky!uunet!gatech!destroyer!gumby!yale!mintaka.lcs.mit.edu!ai-lab!hal.gnu.ai.mit.edu!mikc
  2. From: mikc@hal.gnu.ai.mit.edu (Mike Coughlin)
  3. Newsgroups: comp.lang.forth
  4. Subject: Re: Documenting
  5. Date: 3 Jan 1993 21:59:08 GMT
  6. Organization: /etc/organization
  7. Lines: 74
  8. Message-ID: <1i7njcINNe5f@life.ai.mit.edu>
  9. References: <4195.UUL1.3#5129@willett.pgh.pa.us>
  10. NNTP-Posting-Host: hal.gnu.ai.mit.edu
  11.  
  12. In article <4195.UUL1.3#5129@willett.pgh.pa.us> ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) writes:
  13. >Category 3,  Topic 3
  14. >Message 8         Mon Dec 28, 1992
  15. >ELLIOTT.C                    at 12:26 EST
  16. > ----via CRS Premium Bulletin Board -
  17. >  USR Dual Standard 16.8K  (416) 629-7000
  18. >
  19. > Date: 12-19-92 (13:38)
  20. >   To: ALL
  21. > From: MARK VANDITTA
  22. > Subj: FORTH CODING STYLE
  23. >
  24. > Is it my imagination, or do most Forth programmers lack formal
  25. > instruction in structured coding?  I have found that most Forth
  26. > programmers write code that is even more unlegible than that of C
  27. > programmers raised on DEC Writers.  Why do Forth programmers
  28. > insist on packing so many words on a single line at the sacrifice
  29. > of clarity?  I like Forth, but I cannot tolerate most Forth
  30. > programmer's coding styles. In other lanuages such as Algol,
  31. > PL/I, Pascal, Ada, and C, most formally trained programmers use
  32. > indentation to set off control structures.  I have yet to see any
  33. > non-trivial Forth program written using indentation to show flow
  34. > of control.  It has been proven that indentation leads to code
  35. > that is easier to read and maintain. 
  36. >    <example omitted>
  37. > I had the opportunity the other week to introduce Forth to a few C
  38. > bigot friends of mine.  They all thought it was a neat language,
  39. > but they likened it to APL.  They called it a write only language
  40. > because they thought it was easier to rewrite a Forth program
  41. > than it was to read and modify the existing one.
  42.      Forth programmers have been trained in structured programming,
  43. but most of them have absolutely no clue as to how to write 
  44. comments. This started years ago because Forth's inventor never 
  45. though anybody else would want to read a Forth program.
  46.      One factor in the way Forth source gets written is in the block
  47. structure. There are 16 lines by 64 characters and no tabs, line
  48. feed/carridge return, etc. All the spaces to make up the 1024 chars
  49. in the display are left in. So an indenting style similar to an
  50. assembly language program would produce data on the disk that had
  51. vast numbers of spaces. Writing the source out in lines of Forth
  52. words with few spaces saves disk space. It also results in unreadable
  53. code. Not many Forth programmers think of filling the blank spaces
  54. with comments. Nobody pays much attention to how hard its is for a
  55. non-Forth programmer to read Forth code. If they did then it would
  56. be much easier for Forth programmers to read the code, too. But it
  57. wouldn't be traditional.
  58.      There is a great debate about the use of Forth blocks vs. text
  59. files. The best reason for using text files is to be able to 
  60. indent the code for clarity and to neatly add comments where they 
  61. would look good. This does not seem to enter into the discussion.
  62. Forth programmers think that a few cryptic abbreviations to show
  63. the state of the stack before and after the word executes and the 
  64. use of long word names is all the documentation Forth needs. Ha!
  65. Then they wonder why Forth isn't very popular.
  66.      Forth is easier to understand than other languages that do 
  67. as much (or even less). But it needs as much commenting as 
  68. assembly language, and it doesn't get it. Every assembly language
  69. programmer knows that a program woun't work if it isn't well 
  70. commented. Published assembly language programs are almost always
  71. written with one comment per line plus some extra paragraphs
  72. inclosed in boxes. The uncommented assembly language I've seen
  73. is usually in the middle of Forth programs. Forth is much better
  74. than assembly. Uncomented Forth programs can work. Its just that
  75. only a computer can read them.
  76.      There are Forth programmers who can write clearly commented
  77. source that is easy to understand. You just have to look for a
  78. very long time to find it. There used to be a book about Forth
  79. that discussed good programming style and practice, but it went
  80. out of print since not enough people bought it.
  81.  
  82. -- 
  83.    Michael Coughlin             mikc@gnu.ai.mit.edu  
  84.