home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / shell / 3759 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  5.9 KB

  1. Xref: sparky comp.unix.shell:3759 comp.unix.questions:10637
  2. Path: sparky!uunet!usc!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!friedman
  3. From: friedman@gnu.ai.mit.edu (Noah Friedman)
  4. Newsgroups: comp.unix.shell,comp.unix.questions
  5. Subject: Re: Shell Scripts vs. C programs
  6. Message-ID: <FRIEDMAN.92Sep2045423@nutrimat.gnu.ai.mit.edu>
  7. Date: 2 Sep 92 08:54:23 GMT
  8. References: <1992Aug31.211738.1909@tjhsst.vak12ed.edu> <119@steiny.com>
  9.     <1992Sep1.044434.7193@news.acns.nwu.edu> <121@steiny.com>
  10.     <1992Sep1.173604.15563@u.washington.edu>
  11. Sender: news@ai.mit.edu
  12. Followup-To: comp.unix.shell
  13. Organization: Free Software Foundation, 675 Mass Ave. Cambridge, MA 02139
  14. Lines: 82
  15. In-reply-to: donn@carson.u.washington.edu's message of 1 Sep 92 17:36:04 GMT
  16.  
  17. In article <1992Sep1.173604.15563@u.washington.edu> donn@carson.u.washington.edu (Donn Cave) writes:
  18. >language that would have "software engineering" features for writing large
  19. >systems.  For me, that would mean some level of typing, structured types,
  20. >functional scoping, and some way to deal with code in separate modules,
  21. >but I'm sure there's more to it if one were to consult some standard texts
  22. >on this issue.  Would be nice to be able to create somewhat complex data
  23. >types, e.g., trees, and store "pointers" to functions, but not necessarily
  24. >the way C does it, maybe more like Lisp.  
  25.  
  26.    I've been thinking about this for awhile, especially since I started
  27. using perl.  Having a tool like perl is the right idea for typical unix
  28. applications, filters and so forth---fork is expensive and it's not going
  29. to get better any time soon (vfork is *still* better than a plain COW fork
  30. implementation), and exec is even worse---but perl's grammar and design is
  31. totally broken (sorry, Larry).  The reason why people complain about perl
  32. having the kitchen sink is that it has no uniform design; instead there is
  33. a grab bag of features that look hastily adopted from other programs like
  34. sed, awk, and grep, none of which are very orthogonal.  There are various
  35. annoying context-dependent misfeatures in perl as well, and
  36. multi-dimensional/nested arrays are cumbersome (the associate array
  37. features in awk are much easier to deal with).  Perl also suffers from
  38. being too redundant---there are tons of gratuitous looping constructs that
  39. give programmers lots of different ways to write the same thing and
  40. decrease readability without actually increasing the functionality of the
  41. language (using "unless" and violating the general condition->consequent
  42. order of expression is evil, especially since this is not a fundamental
  43. paradigm of the language).  The idea of function calls being lvalues I find
  44. to be unaesthetic as well.  Perl has lexical scoping, compilation, a
  45. package system for separating namespaces, and "modules" to its credit,
  46. however.  And it's actually powerful enough to do most of the things you
  47. could ever want in a single process, avoiding the aforementioned fork+exec
  48. overhead.  Perl as a general purpose interpreter is no worse than any other
  49. language interpreter, so I think most of the objections made by "unix
  50. purists" are off base.  They should not be complaining about perl's
  51. functionality; they should be complaining about its design.
  52.  
  53.    I would personally like to see a Scheme-oriented scripting
  54. program---perhaps Aubrey Jaffer's scm implementation would do for starters,
  55. though the source code is presently too messy for me to want to touch it.
  56. MIT Scheme is probably too large and too slow to be used for running "shell
  57. scripts", and it's not very portable anymore, at least according to one of
  58. the MIT Scheme hackers I talked to.  It goes without saying that
  59. portability is a vital issue for a program of the "script language" sort.
  60.  
  61.    Scheme has a lot of interesting and powerful primitives, and it is
  62. extremely clean (everything but the low level macro facility, which is
  63. still being ironed out in the various standards drafts).  It has most of
  64. the essential features perl does, and what's missing could be trivially
  65. implemented (like filter-oriented pipelines, regexps, a generic syscall
  66. interface, and some error system to handle unix signals as well as internal
  67. errors).  You might be able to get away with not completely implementing
  68. continuations (I can't imagine using the full power of this in a mere
  69. script to sort the passwd file :-)) or the full tower of numerical types.
  70. Who uses complex numbers in shell scripts?
  71.  
  72.   The main drawback I see at this point is that a Scheme interpreter (even
  73. with a native-code compiler that compiles the script at startup) is likely
  74. to be slower than perl is presently.  To minimize startup cost, most of the
  75. scheme system itself would have to either be written in C (use scheme2c?),
  76. or generated by a program which would byte-compile scheme code and then
  77. dump it in C-style structures and arrays, and then have that compiled into
  78. the real scheme system.  Not my idea of the ideal way to write a scheme
  79. system, but it'll probably run faster.  And I think this would be more
  80. portable than using GNU Emacs' "unexec" method for dumping.
  81.  
  82.    You'd also want to write a library of commonly used subroutines to do
  83. various kinds of field splitting, pattern substitution, and so on.
  84. Although the way you actually do it is bletcherous, one of perl's selling
  85. points is that you can *quickly* write routines to get the job done.
  86. Unless you can do the same sorts of things with relative ease in a Scheme
  87. system, it won't be good enough to replace perl.
  88.  
  89.    Scheme has latent types, rather than manifest ones (i.e. types are
  90. associated with values, not with variables).  Whether this is a good or bad
  91. thing is a religious issue that shouldn't be discussed in either of the
  92. newsgroups to which this is being posted, but just to throw some fuel on
  93. the fire, I prefer latent types for most applications.  :-)
  94.  
  95.    Incidentally, I have a public domain Scheme implementation written in
  96. Perl.  It's missing continuations among other things, but it's still rather
  97. interesting... Anyone have any idea who wrote it?  There wasn't any author
  98. listed in the copy I found.
  99.