home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / scheme / 2117 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  4.4 KB

  1. Path: sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!ames!olivea!mintaka.lcs.mit.edu!ai-lab!zurich.ai.mit.edu!jinx
  2. From: jinx@zurich.ai.mit.edu (Guillermo J. Rozas)
  3. Newsgroups: comp.lang.scheme
  4. Subject: Re: stand-alone executables
  5. Message-ID: <JINX.92Aug31113754@chamarti.ai.mit.edu>
  6. Date: 31 Aug 92 15:37:54 GMT
  7. References: <JIMB.92Aug25053328@occs.cs.oberlin.edu>
  8. Sender: news@ai.mit.edu
  9. Reply-To: jinx@zurich.ai.mit.edu
  10. Distribution: comp
  11. Organization: M.I.T. Artificial Intelligence Lab.
  12. Lines: 82
  13. In-reply-to: jimb@occs.cs.oberlin.edu's message of 25 Aug 92 10:33:28 GMT
  14.  
  15. In article <JIMB.92Aug25053328@occs.cs.oberlin.edu> jimb@occs.cs.oberlin.edu (Jim Blandy) writes:
  16.  
  17. |   In my experience, stand-alone executable files generated by scheme
  18. |   compilers tend to be very large.  For example, compiling the program
  19. |
  20. |       (display "Hello, World!")
  21. |       (newline)
  22. |
  23. |   using the Gambit scheme compiler on an HP9000/375 running BSD produces
  24. |   a 400k executable file.  Last I checked, Chez scheme didn't do too
  25. |   well either (although that was a while ago), and I seem to recall
  26. |   Scheme->C producing a 500k executable file for a program which
  27. |   computes and prints the factorial of a number.
  28. |
  29. |   This seems odd to me.  Gambit's interpreter, gsi, is 400k, which
  30. |   suggests to me that Gambit's standalone generation system just throws
  31. |   the whole interpreter in with your code.
  32. |
  33. |   This is a pretty small sample of scheme systems; is this behavior
  34. |   common?  Are there many schemes out there which generate
  35. |   reasonably-sized executables?  If not, why does everyone find it so
  36. |   difficult to generate them?  Is it so challenging to do the sort of
  37. |   linking C compilers do, and throw away the unnecessary library
  38. |   routines?
  39.  
  40. It is not conceptually difficult.  Just painful in practice.
  41. I'm most familiary (obviously) with MIT Scheme, so most of the
  42. comments below apply to that implementation.  However, I don't think
  43. that they are unique.
  44.  
  45. There are two major obstacles:
  46.  
  47. - Decomposability of the system:
  48.  
  49. The system (runtime support library) must be written in such a way
  50. that it does not depend on the whole thing being around.  Even static
  51. linkers would drag quite a bit of code given the way that a lot of
  52. Lisp systems are written, where, for example, MAP can call ERROR, and
  53. ERROR can call the debugger and the read-EVAL-print loop.
  54.  
  55. It is somewhat more painful (and goes against the grain of what Lisp
  56. programmers have traditionally wanted) to write a system that can't
  57. really depend on any other part of the system being there yet has the
  58. hooks so that they will be used if they are.
  59.  
  60. - Lack of support from external tools:
  61.  
  62. There are little things that have to be compensated for because most
  63. system linkers (e.g. ld) are really only adequate for static languages
  64. such as C and Fortran are static languages with a "main" procedure
  65. that must explictly invoke and initialize the rest.  For example:
  66.  
  67. Lisp programs often include (quoted) constant objects that must be
  68. understood by the GC.  Either they live in the ordinary heap (and the
  69. static code must then copy them on initialization and have some means
  70. to reference them that can be tracked by the GC so that pointers can
  71. be updated when relocated) or you use a GC that does not move (at
  72. least this) stuff around.  Either way, it is a level of complication
  73. that you might not have had otherwise.
  74.  
  75. Lisp programs are not procedure static declarations, but must be
  76. executed (evaluated) in order to arrive at their "ground state".  In
  77. other words, Lisp programs are not only a collection of procedure
  78. definitions, but also some code that needs to be executed when the
  79. code is "loaded" (think for example of map defined as
  80. ``(mapper-procedure car)'').  To solve this one, you can change your
  81. style to have a "main" function and explicit initialization, or you
  82. must pre-run the program before linking so that all initialization is
  83. already done, or you have to do some extra work to make sure that your
  84. main function will invoke the initializers for each of the modules you
  85. are linking.
  86.  
  87. Overall, it is doable, but painful enough that Lisp implementors
  88. (unfortunately) postpone implementation of such a capability.
  89.  
  90. |   I'd like to be able to invoke small scheme programs from the shell and
  91. |   not have it take several seconds to load and occupy several megabytes
  92. |   of swap space.
  93. |   --
  94.  
  95. I agree this would be nice to have, however, I try to use the shell as
  96. little as possible :-).
  97.