home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / misc / 2757 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  2.6 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!network.ucsd.edu!lyapunov.ucsd.edu!mbk
  2. From: mbk@lyapunov.ucsd.edu (Matt Kennel)
  3. Newsgroups: comp.lang.misc
  4. Subject: Re: Small Language Wanted
  5. Date: 21 Aug 1992 21:08:09 GMT
  6. Organization: Institute For Nonlinear Science, UCSD
  7. Lines: 62
  8. Message-ID: <173lvpINNiov@network.ucsd.edu>
  9. References: <BtCFs9.4ox@usenet.ucs.indiana.edu>
  10. NNTP-Posting-Host: lyapunov.ucsd.edu
  11. X-Newsreader: Tin 1.1 PL3
  12.  
  13. mdchaney@fractal.ucs.indiana.edu (M Darrin Chaney) writes:
  14. : Not to fan a flame war, but indeed C++ is _excellent_ for working with
  15. : complex numbers, etc.  And, nobody will accuse you of using an outdated
  16. : language.
  17.  
  18. C++:  complex A, B, C;
  19.  
  20. C = A + B
  21.  
  22. { get A and B, call "+" operator.  Create new temporary structure for
  23.   result by calling complex constructor.  Run "+" operator. 
  24.   call overloaded "=" operator.  Copy into C. Delete temporary.}
  25.  
  26. And can C++ optimize
  27.  
  28. for (i=1; i<1000; i++) {
  29.     <junk not altering A and B>
  30.     C = A + B
  31.     <more junk not altering A and B>
  32.     func(C)
  33. }
  34.  
  35. by taking out C=A+B as a loop invariant?
  36.  
  37. How can it if the "+" and "=" operators could conceivably do *ANYTHING*
  38. which might possibly alter something else somewhere else.
  39.  
  40. With enough effort no doubt, this problem could be fixed to make
  41. code that's not much worse than Fortran-IV.  (The point is that
  42. the algebra of complex numbers and matrices and vector operations restricts
  43. what can happen allowing more optimization.)
  44.  
  45. In case you're wondering, yes I think that OO programming can be a
  46. good thing, even in scientific programs, but I also believe that the
  47. "textbook examples" of classes, i.e. complex numbers and vectors and
  48. matrices are *too important* to do without special treatment.  If it were
  49. possible to do these right, and still as special cases of a fully general
  50. notion, great, but that's not here today.
  51.  
  52. : C is an excellent language for scientific stuff, and C++ even better.
  53.  
  54. Personally, I think C is an excellent language for writing Unix
  55. utilities, and barely tolerable for scientific programs, useful only because
  56. Fortran 77 doesn't have dynamically allocatable memory and structures.
  57. I think that C++ really sucks. (Modula-3 and Eiffel perform that function
  58. better, I think).
  59.  
  60. : Check out the flame-war du jour in soc.college for more information on
  61. : how Scheme "is great|sucks" compared to C which "is great|sucks".
  62.  
  63. sorry, I should contain myself....
  64.  
  65.  
  66. :     Darrin
  67. : -- 
  68.  
  69. --
  70. -Matt Kennel          mbk@inls1.ucsd.edu
  71. -Institute for Nonlinear Science, University of California, San Diego
  72. -*** AD: Archive for nonlinear dynamics papers & programs: FTP to
  73. -***     lyapunov.ucsd.edu, username "anonymous".
  74.