home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / fortran / 3531 < prev    next >
Encoding:
Text File  |  1992-09-11  |  3.4 KB  |  91 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!gatech!hubcap!mjs
  3. From: mjs@hubcap.clemson.edu (M. J. Saltzman)
  4. Subject: Re: Switching from Fortran to C
  5. Message-ID: <1992Sep12.030655.15105@hubcap.clemson.edu>
  6. Organization: Clemson University, Clemson SC
  7. References: <92253.131825BOYDJ@QUCDN.QueensU.CA> <22578@nntp_server.ems.cdc.com> <mac.716244930@depot.cis.ksu.edu.cis.ksu.edu>
  8. Date: Sat, 12 Sep 1992 03:06:55 GMT
  9. Lines: 80
  10.  
  11. OK, I'll take the bait...
  12.  
  13. In article <mac.716244930@depot.cis.ksu.edu.cis.ksu.edu> mac@cis.ksu.edu (Myron A. Calhoun) writes:
  14. >mstemper@ems.cdc.com (Michael Stemper) writes:
  15. >>And if you really want to drive a hard-core C programmer crazy, show them
  16. >>that their C compiler will accept this file:....
  17.  
  18. I'm not a "hard-core" C programmer (I write plenty of Fortran and I've
  19. written my share of Pascal, PL/I, and assembler. too), but my response
  20. to this is:
  21.  
  22. It doesn't bother me (or many C programmers that I know) in the least
  23. that my C compiler accepts this sort of foolishness.  The crazy things
  24. that C compilers accept are showcased annually in the International
  25. Obfuscated C Code Contest, whose results for this year were recently
  26. posted in comp.lang.c.  They are hilarious, and the "Fortran" example
  27. was really kind of cute.  (After all, we're all entitled to a little
  28. fun every now and then...)
  29.  
  30. What bothers me is when people propose to write serious code for use
  31. by other people using these tricks.  They do nothing for readability
  32. or (especially) maintainability.  They require a C programmer trying
  33. to read them to learn a whole new language (even if they already know
  34. Fortran, Pascal, or whatever language is being imitated) and they
  35. force anyone trying to write in the dialect to learn a new language
  36. (in addition to learning C, since you can't really understand what the
  37. code is doing in detail without looking at the native C--especially
  38. when it breaks), since the dialect isn't really native Fortran, 
  39. Pascal, or whatever.
  40.  
  41. >I try to make my C programs look more like Modula 2; 
  42.  
  43. Why?
  44.  
  45. >                                                      here is a module from
  46. >the last big C program I wrote:  the C compiler eats it up.
  47.  
  48. Yeah, but the programmer they hire to maintain the code when you're 
  49. gone will choke on it, and so will your Modula 2 compiler.  What have
  50. you really gained?
  51.  
  52. In the immortal words of sombody else:
  53.     If you want Modula 2, you know where to find it.
  54.  
  55. Below is an edited sample of code in a new language called Myron:
  56.  
  57. >(#includes, #defines, most comments, & similar lines deleted for brevity)
  58.  
  59. Uh huh....
  60.  
  61. >
  62. >------------ cut here ------------ cut here ------------ cut here ------------
  63.  
  64. OK
  65.  
  66. >   Pend_of_sequence  = &sequence[MAXSEQUENCE-1];
  67. >   *(Plast_in_sequence = &sequence[0]) = START_SYMBOL;
  68. >
  69. >   FOR (X = 0; (X < MAXSYMBOLS); X++) THEN
  70. >       implicant_counts[X] = 0;
  71. >   END_FOR
  72.  
  73. Yep.  This really looks like Modula 2, all right.
  74.  
  75. >             FOR (length = (*Pcur_imp_node).implicant_length
  76. >                 ,Pold_symbol = (*Pcur_imp_node).Pconsequent
  77. >                 ,Pnew_symbol = Plast_in_sequence
  78. >                 ,count       = 2    /* Length of shortest implicant */
  79. >                 ;(*--Pnew_symbol == *--Pold_symbol); ) THEN
  80.  
  81. I think this is the worst of both worlds.
  82.  
  83. >------------ cut here ------------ cut here ------------ cut here ------------
  84. >--Myron.
  85. >-- 
  86.  
  87. -- 
  88.         Matthew Saltzman
  89.         Clemson University Math Sciences
  90.         mjs@clemson.edu
  91.