home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / edu / 1329 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  11.0 KB

  1. Xref: sparky comp.edu:1329 comp.lang.fortran:3151
  2. Newsgroups: comp.edu,comp.lang.fortran
  3. Path: sparky!uunet!usc!sdd.hp.com!caen!hellgate.utah.edu!lanl!cochiti.lanl.gov!jlg
  4. From: jlg@cochiti.lanl.gov (Jim Giles)
  5. Subject: Re: Small Language Wanted
  6. Message-ID: <1992Aug25.200646.8930@newshost.lanl.gov>
  7. Sender: news@newshost.lanl.gov
  8. Organization: Los Alamos National Laboratory
  9. References: <DAVIS.92Aug23010605@pacific.mps.ohio-state.edu> <1992Aug25.034553.2990@linus.mitre.org>
  10. Date: Tue, 25 Aug 1992 20:06:46 GMT
  11. Lines: 190
  12.  
  13. In article <1992Aug25.034553.2990@linus.mitre.org>, crawford@church.mitre.org (Randy Crawford) writes:
  14. |> [...]
  15. |> On a single statement basis, I'd agree: FORTRAN has it over C in expressing
  16. |> numeric computations (you forgot to mention the problems C has in evaluating
  17. |> expressions having mixed numeric types).  But if you've ever attempted to
  18. |> modify or even read a large FORTRAN program, you've experienced what I have --
  19. |> a rat's nest.  [...]
  20.  
  21. Actually, the "rat's nest" problem is about the same for both languages.
  22. The basic problem is that most *programmers* write in an unstructured
  23. way.  C programmers even call themselves (proudly no less!) "hackers".
  24. To extemporize a program and then `hack' at it until it works is *NOT* 
  25. a structured way to proceed (yes, that *is* the meaning of the term
  26. "hacker").
  27.  
  28. |> [...]     I don't believe it's possible to write modular FORTRAN code:
  29. |> at least, I've never seen it. [...]
  30.  
  31. I have.  That's all I write in any language. This is true of *any* language 
  32. I use.  Modular coding is a language independent concept and can be done 
  33. in assembler!  In fact, the basis of "structured programming" (the original
  34. definition of the term - not its modern useless meaning) is to write the
  35. algorithm abstractly and select the actual language you're going to use
  36. *afterwords*.  Structured programming consists of iteratively refining
  37. the algorithm to more and more specific forms - the *last* refinement is 
  38. to finally express the sub-modules of the algorithm in the actual programming 
  39. language(s).  In a well designed environment, there should be several
  40. languages available and they should be inter-callable.
  41.  
  42. |> [...]                         And unless FORTRAN 90 eliminates constructs
  43. |> like computed gotos, FORTRAN code will never become structured or modular.
  44.  
  45. Computed GOTOs are not relevant to the issue of modular code.  It is possible
  46. to misuse setjump/longjump in C to a much *more* dangerous extent (the jumps
  47. are not local), yet you don't claim that this makes modular code difficult
  48. in C.  Even GOTOs themselves are less restricted in C than in Fortran (you
  49. can jump *into* a nested structure from outside).
  50.  
  51. Computed GOTOs have nearly *exactly* the same semantics as C's switch
  52. (including the fall-through unless the user explicitly breaks out).  True,
  53. the computed GOTO is not required to properly nest, but C's ordinary GOTO
  54. isn't either.
  55.  
  56. |> [...]
  57. |> >  The only real thing that I miss in Fortran 77 is a pointer type.  There are
  58. |> >many times when I wanted to pass pointers to functions through common blocks.
  59. |> 
  60. |> I'd say this statement is a perfect example of where the difficulty lies in 
  61. |> FORTRAN: unstructured programming conventions and poor software engineering 
  62. |> practices.  [...]
  63.  
  64. You mean like C's overuse of explicit pointers?  This is usually a *very*
  65. poor software engineering practice.  It's worse than overusing GOTOs and
  66. results in similar symptoms (spaghetti).  Things for which aliasing is not 
  67. explicitly part of what you want to do should *never* be forced be implemented 
  68. with explicit pointers.  This includes such things as dynamic memory, recursive
  69. data structures, aggregate reshaping (that is, treating a 10x10 array as
  70. a 100 long rank-one array for a while), etc..
  71.  
  72. |> [...]  The problem lies in FORTRAN's common blocks and the popular 
  73. |> excessive use of global variables, [..]
  74.  
  75. Most C programs (that I've seen) excessively use globals too.  
  76. True, C has a poor MODULE-like functionality in the form of file-scoping 
  77. rules.  Most Fortrans already have modules or soon will.  Even so, *real* 
  78. modules have more similarity to COMMONs than to file-scoping: being named 
  79. aggregates.  MODULEs can hold procedures as well as data (which makes
  80. MODULE-private objects useful) and MODULEs are name associated instead
  81. of storage associated, but those are the only differences from COMMON
  82. (important though they are!).  C files are not *named* aggregates though.
  83. All objects exported from them are *individually* global.  This is a much
  84. more serious deficiency.
  85.  
  86. |> [...]                                    poor control over subroutine argument 
  87. |> passing-by-value/passing-by-reference, [...]
  88.  
  89. C *requires* explicit user selection of these.  I've never found this
  90. level of "control" particularly useful.  Especially since it is sometimes
  91. desirable to alter a procedure which does one so that is does the other:
  92. in C this requires altering all the *calls* to the procedure.
  93.  
  94. |> [...]                           NO user-defined data types, no recursion, [...]
  95.  
  96. Well, yes and no.  Not having these things is better than having them in
  97. a poorly implemented form (as C's user defined types are).  Yes, recursion
  98. is sometimes useful (though always less efficient - or, at best, equal *if*
  99. your optimizer is up to snuff).  Missing featurers can always be added by 
  100. future standards, poorly designed ones are very difficult to remove.  Both 
  101. of these are in Fortran 90.
  102.  
  103. |> [...]
  104. |> poor-to-nonexistant looping constructs, [...]
  105.  
  106. Huh?  Minor syntactic sugar is missing.  This makes *some* loops harder
  107. to *read*.  C also has illegible looping constructs - especially the 
  108. ubiquitous for() loop (which some style guides recommend for *all* 
  109. C loops).  True, I'd like different syntax for WHILE and UNTIL loops,
  110. different syntax for N TIMES loops, loops with iteration variables
  111. defined (both covarying, and independently varying), etc. (in fact, 
  112. I think this is a very improtant issue since I think syntax is the
  113. most important aspect of a language's legibility).  Neither language 
  114. has a full set and those that C has are equipped with built-in 
  115. legibility problems.  Fortran 90 is closer than either to a well
  116. designed set of control flow constructs in general - loops being
  117. a particular case.
  118.  
  119. |> [...]                                a dependency on gotos (and the very 
  120. |> existence of computed gotos)  to a lack of [...] switch/case constructs, 
  121. |> etc, etc.
  122.  
  123. This is being inconsistent.  Computed GOTO and C's switch have nearly
  124. identical semantics.  Just because C doesn't use the four characters
  125. `g', `o', `t', and `o' doesn't alter this.  If your complaint is that
  126. *neither* language has a really *good* select/case feature, then I would
  127. agree.  Fortran 90 does is an improvement in this respect over both.
  128.  
  129. |> [... reordered ...] and archaic conditionals from .NE.
  130.  
  131. OK.  On the other hand, a preprocessor which converts <, <=, ==, /= (I would
  132. prefer ~= here), >=, and > to their corresponding Fortran is trivial to write.  
  133. I agree, these should be in the standard - they *are* in Fortran 90.  Also, 
  134. .AND. should be written as /\, .OR. should be written as \/, .NOT. should be 
  135. written as ~, and .XOR. *could* be >< (though ASCII is inadequate to present 
  136. a really good xor operator), etc. - the committee was timid in its additions.
  137.  
  138. If you want to complain about bad operators though, C is the language with 
  139. the worst.  Over 40 operators and 15 precedence levels (more than any other
  140. language I've ever seen).  Many of the operators are poorly chosen from the
  141. available character set and are, as a result, difficult to read as well as
  142. difficult to learn.  The operators are at odds with the use of the same
  143. characters in other conventional notations.  For example `||' in mathematics
  144. means "is parallel to"; `|' in most gramatical notations is "exclusive or"
  145. (and elsewhere in UNIX is "pipe"); `!' of course is an exclamation (or a
  146. factorial); K&R C doesn't allow unary plus (why?); unary minus has a different
  147. precendence than infix minus; there are, unnecessarily, *two* selector operators
  148. of `struct' variables (depending on whether they are pointed at or not); etc..
  149. Add to that: contrary to human-factors studies on productivity and syntax,
  150. C has expression level operators which cause side-effects.
  151.  
  152. |> [...]
  153. |> While none of these affect the ability of the language to express numeric
  154. |> computation on a single statement basis, any program of more than about 200
  155. |> lines begins to get unwieldy and critical mass occurs at about 1000 lines.
  156. |> This is unacceptable in modern programming languages, and _I_ think it
  157. |> relegates FORTRAN and her afficionados to the dark ages of software engineering.
  158.  
  159. I also would put the trade-off between C and Fortran at about 200 to 1000
  160. lines of code.  Fortran is much better for the larger codes.  C is like 
  161. Basic in that it's mainly good for trying out simple algorithms in the small
  162. and not for large projects at all.  *If* your algorithm can be efficiently
  163. decomposed into lots of small independent procedures that don't need to
  164. process arrays as first-class objects, C *can* still be used effectively.
  165.  
  166. |> [...]
  167. |> I think the real advantage that C has over FORTRAN (and Pascal has over C) is
  168. |> especially among undisciplined numerical programmers, where the "better" 
  169. |> language allows sufficient expressiveness to solve the problem, yet less 
  170. |> opportunity to write bad code.  And it's easier for "part-time" programmers to 
  171. |> write bad code in FORTRAN than in C.
  172.  
  173. Well, it's harder for part-time programmers to learn enough C to write
  174. good code with it.  The typical learning curve for C is longer than for any
  175. other language I'm familiar with.  Parttime programmers are, by definition, 
  176. not people with the time to spend on this kind of learning - even if C 
  177. coding really did result in better coding practices (which I've not noticed 
  178. to be true).  With respect to learning, Pascal and C are on the opposite
  179. ends of the spectrum, with Fortran between them.  For ad-hoc learning - 
  180. typified by the usual C approach - Fortran is the easiest to learn of all: 
  181. Pascal was designed to be a teaching tool, but only in a well-ordered 
  182. learning environment.
  183.  
  184. For a C-level language which is much better designed and *vastly* easier to 
  185. learn and to use, try Turing (invented at the University of Toronto).  It's 
  186. slowly becoming more widely available.  There are probably numerous others
  187. I'm not aware of.
  188.  
  189. |> As I see it, a programming language has to be judged in the real world not by 
  190. |> what programmers can do _with_ it, but by what they can do _to_ it.
  191.  
  192. Oh, well if you want *extensible* languages, the functional languages (Scheme,
  193. ML, Haskell, etc.) are the best.  Object oriented languages come in a distant
  194. second best (with C++ trailing that pack in terms of design quality).  A close
  195. third comes in the form of languages with generic procedure interfaces (a`la
  196. Ada, though Ada has other problems - though it's still better than C overall).
  197. It's not clear but that generic procedures might not be better than the object
  198. oriented approach, but with Ada the only widespread example of the former, it's
  199. hard to tell.
  200.  
  201. -- 
  202. J. Giles
  203.