home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / compiler / 1385 < prev    next >
Encoding:
Internet Message Format  |  1992-08-15  |  4.0 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!udel!gvls1!faatcrl!iecc!compilers-sender
  2. From: pardo@cs.washington.edu (David Keppel)
  3. Newsgroups: comp.compilers
  4. Subject: Re: Why is compiled basic slower than C? (Basic is the future)
  5. Keywords: interpreter, performance, Basic, smalltalk
  6. Message-ID: <92-08-084@comp.compilers>
  7. Date: 15 Aug 92 22:40:03 GMT
  8. References: <92-08-064@comp.compilers> <92-08-080@comp.compilers>
  9. Sender: compilers-sender@iecc.cambridge.ma.us
  10. Reply-To: pardo@cs.washington.edu (David Keppel)
  11. Organization: Computer Science & Engineering, U. of Washington, Seattle
  12. Lines: 88
  13. Approved: compilers@iecc.cambridge.ma.us
  14.  
  15. >>[Why isn't compile BASIC as fast as C?]
  16. >[It's too dynamic.]
  17.  
  18. I'm surprised nobody has mentioned the Deutsch-Shiffman Smalltalk-80
  19. virtual machine implementation or the SELF system.  Neither system is a
  20. `traditional' compiler, but both run fast and are examples of `dynamic'
  21. languages (little information for static optimization) with efficient
  22. implementations.  Their results shold apply to BASIC and to some other
  23. languages.
  24.  
  25. Smalltalk programs lack type declarations.  Programmers are encouraged to
  26. modularize extensively, resulting in very small procedures (methods).
  27. Some common control structures are implemented using method invocation.
  28. Smalltalk is more dynamic than basic, yet a ``fairly straightforward''
  29. dynamic compilation implemenation of the Smalltalk-80 Virtual machine runs
  30. benchmarks within an order of magnitude of compiled C, while an optimized
  31. interpreter is 2X slower.
  32.  
  33. SELF is more dynamic than even Smalltalk-80.  Even primitive control
  34. structures (if/then/else, loops) are built using method invocation [*].
  35. Yet on a set of benchmarks, SELF programs run with an optimizing dynamic
  36. compiler run at about half the speed of modestly-optimized C programs (on
  37. a SPARC, using the default pcc-based compiler with optimization turned
  38. on).  With an interpretive implementation, SELF programs might be two
  39. orders of magnitude slower than it is; indeed, programs compiled without
  40. inlining (procedure integration) are about that much slower.
  41.  
  42. The disadvantages of dynamic compilation generally include (a) the need to
  43. pay for compilation at runtime and (b) a lack of ways to share code (e.g.,
  44. each instance of program `foo' has a private copy of the compiled machine
  45. code).  The first sometimes results in long startup times or variability
  46. in execution time.  The latter results in large(r) memory demands.
  47.  
  48. [*] Note that in Smalltalk, some control structures appear to be message
  49. sends but are inlined; changing the implementation code for the control
  50. structures does not change the system's behavior.  In SELF, the control
  51. structures are treated uniformly as message sends.
  52.  
  53. 5 References Follow:
  54.  
  55. %A Craig Chambers
  56. %T The Design and Implementation of the S\s-2ELF\s+2 Compiler,
  57. an Optimizing Compiler for Object-Oriented Programming Languages
  58. %R Ph.D. dissertation, Department of Computer Science, Stanford
  59. University
  60.  
  61. %A Craig Chambers
  62. %A David Ungar
  63. %T Making Pure Object-Oriented Languages Practical
  64. %J OOPSLA '91 Proceedings; SIGPLAN Notices
  65. %V 26
  66. %N 11
  67. %P 1-15
  68. %C Phoenix, AZ
  69. %D November 1991
  70.  
  71. %A Craig Chambers
  72. %A David Ungar
  73. %A Elgin Lee
  74. %T An Efficient Implementation of SELF, a Dynamically-Typed
  75. Object-Oriented Language Based on Prototypes
  76. %J OOPSLA '89 Proceedings
  77. %D October 1-6 1989
  78. %P 49-70
  79.  
  80. %A Craig Chambers
  81. %A David Ungar
  82. %T Customization: Obptimizing Compiler Technology for SELF, a
  83. Dynamically-Typed Object-Oriented Programming Language
  84. %J 0-89791-306-X/89/006/0146
  85. %D 1989
  86. %P 146-160
  87.  
  88. %A Peter Deutsch
  89. %A Alan M. Schiffman
  90. %T Efficient Implementation of the Smalltalk-80 System
  91. %J 11th Annual Symposium on Principles of Programming Languages
  92. (POPL 11)
  93. %D January 1984
  94. %P 297-302
  95.  
  96.     ;-D on  ( Just call me Mr. Runtime! )  Pardo
  97. [Many APL systems (other than IBM's) also compile on the fly since it can't
  98. usually tell what the types and array rank of variables will be until a
  99. procedure is actually called. -John]
  100. -- 
  101. Send compilers articles to compilers@iecc.cambridge.ma.us or
  102. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  103.