home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / compiler / 1374 < prev    next >
Encoding:
Text File  |  1992-08-15  |  5.9 KB  |  103 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!wupost!gumby!yale!mintaka.lcs.mit.edu!spdcc!iecc!compilers-sender
  3. From: burley@geech.gnu.ai.mit.edu (Craig Burley)
  4. Subject: Re: Why is compiled basic slower than C? (Basic is the future)
  5. Reply-To: burley@geech.gnu.ai.mit.edu (Craig Burley)
  6. Organization: Free Software Foundation 545 Tech Square Cambridge, MA 02139
  7. Date: Fri, 14 Aug 1992 19:14:18 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <92-08-073@comp.compilers>
  10. References: <92-08-042@comp.compilers> <92-08-064@comp.compilers>
  11. Keywords: Basic, performance
  12. Sender: compilers-sender@iecc.cambridge.ma.us
  13. Lines: 88
  14.  
  15. scott@bbx.basis.com (Scott Amspoker) writes:
  16.  
  17.    I just don't think interpreted languages compile well.  If they do then
  18.    they really aren't exploiting the special strengths of interpretation.
  19.    You end up with the worst of both worlds.
  20.  
  21. I think interpreted languages _could_ compile well if _lots_ of effort
  22. were expended.  However, that kind of effort probably isn't worth it --
  23. the performance gains compared to the effort, that is -- when contrasted
  24. to the effort expended in buying new, faster processors, making the
  25. interpreters run faster (often quite easy), translating programs to
  26. maintenable code in a language designed for compilation, and so on.
  27.  
  28. I remember a discussion with rms (GNU EMACS author) regarding TECO, the
  29. language in which he first wrote EMACS.  TECO was (and still is,
  30. primarily) an interpreted language (well, it's an editor, kind of like the
  31. MS-DOS DEBUG program is a partition editor :-).  He told me about how
  32. someone we both knew had developed (or help develop) a compiler for TECO
  33. and was prepared to demonstrate its superiority in benchmarks.  But
  34. submitting one simple case (something like deleting every other line in
  35. the file) proved the opposite.  (Of course, TECO is probably like APL in
  36. that the time it takes to read in source code and figure out what it means
  37. is minimal, as compared to C, FORTRAN, and COBOL.  So the penalty for
  38. being an interpreter could be seen as significantly lower for terse
  39. languages like TECO and APL, higher for verbose languages like BASIC,
  40. FORTRAN, and COBOL.)
  41.  
  42. As already mentioned, the way a language is _expected_ by a program to be
  43. implemented has a noticable effect on how code is written for that
  44. language.  So do language features, of course.
  45.  
  46. C has facilities for easily denoting static and automatic storage, but not
  47. for heap storage or automatically readjustable storage.  C can't even have
  48. functions that return strings without requiring the programmer to impose
  49. one method or another for managing the strings (contrasted to PL/I, which
  50. has the facility and leaves imposition of the technique to the compiler
  51. designers).  Thus, C programmers are acutely aware of what techniques are
  52. likely to be expensive -- if it's easy to do in the raw C language, it's
  53. likely to be fast, otherwise....  Add to that the awareness that C is a
  54. compiled language, and C programmers realize that it's often better to
  55. have lots of _written_ code that expresses a complicated implementation in
  56. an optimal manner using fundamental features of the language.
  57.  
  58. BASIC has facilities for easily denoting readjustable storage such as
  59. strings, arrays, and so on, and it tends to be implemented as an
  60. interpreter.  (The Dartmouth implementation has never been an interpreter,
  61. I understand, nor was the implementation whose internals I hacked as a
  62. teenager -- but the latter offered an interpretive environment yet no
  63. compiled environment, e.g. you couldn't really get the output of the
  64. compiler, just execute it by typing RUN.)  Thus, programmers naturally
  65. tend to use the more concise notations for higher-level constructs offered
  66. by BASIC rather than try and reengineer them using what they think will be
  67. faster (but more verbose) low-level operations, especially given that an
  68. interpreter tends to "dislike" verbosity.  (On the other hand, I often
  69. wrote utility programs in BASIC and consciously chose to use integer
  70. variables to manipulate characters in critical areas of the code since I
  71. knew that the string operations were much slower.  But then I knew my
  72. particular processor compiled, rather than interpreted, my programs --
  73. once per RUN command.)
  74.  
  75. Of course, what we are discussing generally applies to one or two "slices"
  76. of the compiled vs. interpreted issue.  One such slice is whether there is
  77. a separate compilation phase.  Another is the way in which the user
  78. interacts with the processor when developing code.  There is another major
  79. issue regarding interpretation which puts both BASIC and C in the
  80. "compiled" camp: whether the running program has a means to modify itself
  81. at run time.  LISP, for example, belongs in the "interpreted" camp.
  82. Looked at in this light, it would seem that a good BASIC compiler would be
  83. easier to build than a good LISP compiler, since the latter has to worry
  84. about the running program, in effect, changing itself.  Yet, from what
  85. little I know of LISP, there apparently are a number of quite good LISP
  86. compilers out there.  This suggests that perhaps the effort needed to make
  87. a really good BASIC compiler isn't quite so high.  Some of the techniques
  88. I've learned about in doing a good job of compiling FORTRAN programs
  89. (especially dusty decks that use no formal loop control but GOTO instead),
  90. plus others I've dreamt up that aren't needed (generally) in compilers for
  91. languages like C, wouldn't be hard to implement in this day and age and
  92. would probably make lots of BASIC programs run quite fast.
  93.  
  94. Hmm, anyone want to fund me to develop GNU BASIC now that I'm winding up
  95. doing GNU FORTRAN?  I might as well reach even earlier into my childhood!
  96. (Heck, I'm even open to doing GNU AID [by JOSS] or a GNU simulator for the
  97. PDP-8. :-)
  98. --
  99. James Craig Burley, Software Craftsperson    burley@gnu.ai.mit.edu
  100. -- 
  101. Send compilers articles to compilers@iecc.cambridge.ma.us or
  102. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  103.