home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / LISP1.ZIP / LISP1.TXT
Encoding:
Text File  |  1987-01-12  |  15.0 KB  |  3 lines

  1. Copyright 1984 by Gary M. Rader
  2. ╔═════════════════════════════════════════════════════════════════════════════╗
  3. ║                   Why Not Lisp?                      ║
  4. ║                                          ║
  5. ║                    by                          ║
  6. ║                                          ║
  7. ║                   Gary M. Rader                      ║
  8. ╚═════════════════════════════════════════════════════════════════════════════╝
  9.  
  10.  
  11. ┌──────────────────────────────────┐
  12. │ Introduction               │
  13. └──────────────────────────────────┘
  14.  
  15.            Browsing  through  almost any personal computer journal
  16.       will    yield  at  least  one  (if not many) programs computer
  17.       hobbyists can use on their personal computer. These programs
  18.       are  invariably  written  in    BASIC.    Occasionally one finds
  19.       programs written in Pascal, Assembly or, in what seems to be
  20.       the  current    favorite  of  software    developers,  C.  Other
  21.       languages  are mentioned in articles, often without programs
  22.       -  Fortran, Cobol, Forth, APL, Modula-2, Ada, and even Logo.
  23.  
  24.       The  language  that  never seems to appear is Lisp. Why? The
  25.       impression  is  that Lisp is either subhuman (subcomputer?),
  26.       superhuman,  or  beyond comprehension. This article examines
  27.       some    of  the strengths and weaknesses of Lisp, and compares
  28.       it to other microcomputer languages.
  29.  
  30. ┌──────────────────────────────────┐
  31. │ History               │
  32. └──────────────────────────────────┘
  33.  
  34.            Lisp   was  one    of  the  first    high  level  languages
  35.       developed  for  digital  computers.  Fortran    and Cobol were
  36.       developed  in  the  same time frame. Unlike those languages,
  37.       Lisp    has  never  been  standardized,  and  several dialects
  38.       exist.   MacLisp   from   the   Massachusetts  Institute  of
  39.       Technology  (MIT) and InterLisp from Stanford University are
  40.       two  main  dialects.    However,  one  dialect    can  generally
  41.       imitate another so lack of standardization usually causes no
  42.       serious problem.
  43.  
  44.            Lisp  was initially developed by John McCarthy while at
  45.       MIT.    Traditionally,    it  has  been  used  mainly for symbol
  46.       manipulation,   primarily   in   the     area    of  artificial
  47.       intelligence.  Symbol  manipulation  is  the    complement  of
  48.       arithmetic.  It deals with structures as opposed to numbers.
  49.       Probably  the  most familiar symbol manipulation application
  50.       is  a  word  processing program in which words (symbols) are
  51.       manipulated. Other examples include compilers, interpreters,
  52.       data base systems, computer games, and business graphics. In
  53.       the  area of natural language processing, pluralizing a noun
  54.       such     as   "key"   to   "keys"  is  an  example  of  symbol
  55.       manipulation.
  56.  
  57.            Historically,  Lisp  systems  were  slow  with  minimal
  58.       arithmetic   capabilities.   These  deficiencies  have  been
  59.       largely  overcome, but the image persists and Lisp is rarely
  60.       found  outside  university  environments. Another reason for
  61.       its  nonacceptance  was  the lack of good tutorial material.
  62.       The  arrival    of  Winston  and  Horn's  excellent  book LISP
  63.       (Addison  Wesley, 1981, paper) has rectified this situation.
  64.       (EDITOR'S  NOTE:  Apparently,  laziness  is  the  only valid
  65.       remaining  reason  not  to  learn Lisp.) This is the book of
  66.       choice for learning Lisp.
  67.  
  68. ┌──────────────────────────────────┐
  69. │ What Distinguishes Lisp?       │
  70. └──────────────────────────────────┘
  71.  
  72.            What Distinguishes Lisp from other Languages?
  73.  
  74.       1.   First,  Lisp  is  interactive, like BASIC and APL. This
  75.       greatly  speeds  program development and debugging. Like APL
  76.       (and     partly   like    BASIC)    variables  are    not  declared.
  77.       Developed programs can be compiled for increased speed.
  78.  
  79.       2.   One  of Lisp's most powerful features is its ability to
  80.       generate  code  and  execute    it.  For example, to satisfy a
  81.       user's  query,  a  data base program might first generate an
  82.       appropriate  program    and  then execute (or "evaluate" as we
  83.       say  in  Lisp)  it.  APL  has  a similar capability. This is
  84.       possible  because Lisp programs and Lisp data have identical
  85.       structures.
  86.  
  87.       3.   Lisp  compilers    are  unique  in that they can handle a
  88.       mixture  of  both  compiled  and  interpreted code. That is,
  89.       under Lisp a system of interpreted AND compiled programs can
  90.       be  run!  Some  of  these  programs can be compiled, and the
  91.       others  will    be  interpreted. This allows a program to have
  92.       the  speed  of  a  compiled  program together with the above
  93.       mentioned flexibility of "evaluating" generated code.
  94.  
  95.       4.   Various    types  of  macros  facilitate translations and
  96.       redefinition    of  the  Lisp  language.  New languages can be
  97.       built from Lisp relatively easily using macros. The original
  98.       Logo was initially created this way.
  99.  
  100.       5.   Another    powerful  feature is that of function types in
  101.       which  the  number  of  arguments  can be variable or fixed.
  102.       These arguments can be either evaluated or unevaluated. Most
  103.       languages  require  the number of arguments to be fixed. APL
  104.       allows  a  variable  number (as long as it is either 0, 1 or
  105.       2).  The  Lisp  function  PLUS  is a built-in function which
  106.       takes  a variable number of arguments. It can be used to add
  107.       an indefinite number of numbers, not just a pair of numbers.
  108.       The  evaluated/unevaluated  feature  is  similar to call-by-
  109.       value and call-by-name used in other languages.
  110.  
  111.       6.   "Bignums" permit unlimited precision integer arithmetic
  112.       thereby  eliminating    the  problem  of  round-off errors. In
  113.       certain  engineering    and applied mathematics situations the
  114.       problem of round-off can be very serious.
  115.  
  116.       7.   Strings,   functions, and  variable  names  can    be  of
  117.       unlimited  length.  This  allows  the creation of completely
  118.       descriptive names without the need for abbreviations.
  119.  
  120.       8.   The  main Lisp data structure is the linked list, which
  121.       allows  the development of general structures, even circular
  122.       graphs.  The    links  (pointers) are transparent to the user.
  123.       Other  languages such as C allow this capability through the
  124.       explicit   manipulation  of  pointers.  Linked  lists  allow
  125.       certain  operations  to  be  performed much more efficiently
  126.       than when arrays are used.
  127.  
  128.            Consider  an  array  of    numbers, say X(1), X(2), X(3),
  129.       etc.    To  insert  a new third element in this array we shift
  130.       each    element  to the next element in the array and set X(3)
  131.       to  the new number. In Lisp, this is accomplished by linking
  132.       X(2) to the new element, and then linking the new element to
  133.       X(3).  For  long  sequences  the  linked  list  approach  is
  134.       significantly faster than using arrays.
  135.  
  136.       9.   Lisp is a functional language - it uses function calls,
  137.       and  this  makes  it    structured, almost naturally. All Lisp
  138.       programs  are systems of functions with a top level function
  139.       calling subfunctions and so on. New functions can be defined
  140.       in  isolation  and  used  as    if  they  were    primitive Lisp
  141.       operations.
  142.  
  143.       10.  Lisp  has  perhaps  the    most powerful set of debugging
  144.       features  of    any  language. Break points can be set and the
  145.       environment    examined   when  a  break  occurs.  The  input
  146.       arguments  and  results of executing specified functions can
  147.       be  displayed  selectively during program execution. You can
  148.       create   unique   and   powerful   debugging    facilities  by
  149.       appropriately  redefining  the "evaluate function" mechanism
  150.       of Lisp.
  151.  
  152. ┌──────────────────────────────────┐
  153. │ Drawbacks               │
  154. └──────────────────────────────────┘
  155.  
  156.       1.   One  drawback of present day Lisp is the reclamation of
  157.       memory.  Referred  to  as  "garbage  collecting,"  it occurs
  158.       automatically  when no free memory is available for creating
  159.       new  lists  or  strings  (BASIC  has    a  similar  drawback).
  160.       Processing stops (for a few seconds) until all unused memory
  161.       has  been  reclaimed. This can happen at any time during the
  162.       execution  of a program. In many cases it will be unnoticed,
  163.       but  it  can    happen    while a line is being displayed on the
  164.       screen! This creates quite a shock and can lead new users to
  165.       believe  the system has crashed. This also presents problems
  166.       for real time programming.
  167.  
  168.            The problem can be reduced when necessary by explicitly
  169.       calling the garbage collector at points in the program where
  170.       the    user   will  not  notice,  and    by  pursuing  "garbage
  171.       collectionless  programming"  (by minimizing the creation of
  172.       new lists). Research on incremental garbage collectors which
  173.       reclaim a little bit of memory with each new usage of memory
  174.       will,  hopefully, solve  this  problem.  Compiling  programs
  175.       reduces  the    length of garbage collections as compiled code
  176.       does not need to be processed.
  177.  
  178.            Despite     the   negative   impression   created    above,
  179.       automatic  memory  management  is  also  one of Lisp's great
  180.       strengths.  It  allows  the  programmer  to  concentrate  on
  181.       solving  the    problem  at  hand  without being distracted by
  182.       conceptually    irrelevant  details  concerning  memory (e.g.,
  183.       variable  declaration,  requesting memory from the operating
  184.       system, and  returning  memory  when no longer needed). This
  185.       undoubtedly is an important reason for Lisp's preeminence in
  186.       the world of artificial intelligence.
  187.  
  188.       2.   Using  lists instead of arrays requires more memory, as
  189.       space for links must generally be provided.
  190.  
  191.       3.   As data and programs can be widely dispersed in memory,
  192.       using  Lisp  in a virtual memory environment can cause speed
  193.       degradation.    While  following links to a desired data item,
  194.       the  page containing the actual item might be swapped out in
  195.       the  course  of tracking it down! Of course, this can happen
  196.       in  other languages such as C in which pointers can point to
  197.       other pointers, which point to other pointers.
  198.  
  199.       4.   Many   people   complain   that     Lisp    has  too  many
  200.       parentheses.    This  is a prejudice, not a drawback. Usually,
  201.       if  functions  and  data  are  suitably  formatted  ("pretty
  202.       printed"),  this  objection disappears. For those preferring
  203.       fewer  parentheses,  the  Lisp  driver  can  be redefined to
  204.       provide it. (This was done for the Logo syntax.)
  205.  
  206. ┌──────────────────────────────────┐
  207. │ Lisp on the IBM PC           │
  208. └──────────────────────────────────┘
  209.  
  210.            Several    Lisps  are currently available for the IBM PC.
  211.       The Soft Warehouse sells muLISP-83 (also sold by Microsoft),
  212.       Integral  Quality  markets  IQLISP,  and Norell Data Systems
  213.       offers LISP/88.
  214.  
  215.            I  have    used muLISP-83 for almost half a year and have
  216.       been    pleasantly  impressed  by  its performance. I have not
  217.       used    IQLISP    but  from Integral Quality's brochure it seems
  218.       that    it is a fully functional Lisp. LISP/88 has just become
  219.       available  for  distribution,  and I have no experience with
  220.       this product.
  221.  
  222.            muLISP  enforces  completely  structured programming by
  223.       not  having a GOTO command.(However, exits from loops can be
  224.       efficiently performed using the THROW/CATCH combination.) In
  225.       addition  to    the  expected  functionality,  muLISP provides
  226.       access to the PC's BIOS through its REGISTER, INTERRUPT, and
  227.       PORTIO  commands.  This  is  a  useful feature for it allows
  228.       programmers  to  easily  incorporate    graphics,  sound, game
  229.       paddle communication, and more in their programs. Random I/O
  230.       is  available.  muLISP  does    not provide arrays or floating
  231.       point  numbers.  (However  the  Soft    Warehouse is currently
  232.       implementing    floating slash - i.e., floating point in which
  233.       the  precision  is user-defined. This prevents the round-off
  234.       problem from resurfacing.)
  235.  
  236.            A program development system and a debugging system are
  237.       included  with  muLISP  along  with utility files containing
  238.       libraries  of  MacLisp  and  InterLisp functions. An on-line
  239.       tutorial  for  learning  Lisp  is  also  included. (The Soft
  240.       Warehouse  had  developed a tutorial correlated with Winston
  241.       and  Horn's  LISP  book  but  Addison Wesley, the publisher,
  242.       demanded a royalty!)
  243.  
  244.            A   nice   feature   for  program  developers  is  that
  245.       application  programs  written  in  muLISP  do  not  require
  246.       customers  to own the full muLISP system. A small royalty is
  247.       paid    for  use  of  the  muLISP runtime system. Programs are
  248.       distributed as .COM files.
  249.  
  250.            IQLISP  uses all of the PC's memory while muLISP uses a
  251.       maximum of 256K bytes. Arrays and floating point numbers are
  252.       provided  as    is  8087  support. IQLISP does not have random
  253.       I/O.
  254.  
  255.            Both Lisps allow user-defined machine language routines
  256.       to  be  called from within programs. Both include a "string"
  257.       data    type.  muLISP  is  allegedly  4 to 7 times faster than
  258.       IQLISP.  One    reason    is  that muLISP functions are compiled
  259.       into    "distilled"  code  (similar to Pascal's p-code) before
  260.       interpretation. Another is that IQLISP accommodates a larger
  261.       address space.
  262.  
  263.            Both  companies    state  they  will  be  offering a Lisp
  264.       compiler.  When  I  contacted  Integral Quality last Spring,
  265.       they    indicated  that  a Lisp compiler would be available by
  266.       now.    To my knowledge, it is not yet available. The compiler
  267.       from the Soft Warehouse will be ready in late 1984.
  268.  
  269.            LISP/88    may  or may not be in the same league as these
  270.       two.    However,  it  definitely  has  one notable feature - a
  271.       price of $49.95!
  272.  
  273. ┌──────────────────────────────────┐
  274. │ Conclusion               │
  275. └──────────────────────────────────┘
  276.  
  277.            Unjustified    prejudices    continue    to    restrain
  278.       microcomputer  users    from  learning and using Lisp. Several
  279.       quality  microcomputer  implementations  are available along
  280.       with    an  excellent  book  for  learning Lisp. Lisp provides
  281.       powerful  capabilities,  many  of  which  are unavailable in
  282.       other languages.
  283.  
  284.            Three  Lisps  are  currently available for the IBM PC -
  285.       muLISP,  IQLISP, and LISP/88. A review of muLISP, and IQLISP
  286.       appears in PC Magazine (December, 1983).
  287.  
  288.  
  289.              ┌───────────────────────────────────────┐
  290.              │     Products mentioned in this article  │
  291.              ├───────────────────────────────────────┤
  292.              │                         │
  293.              │    IQLISP ($175)                 │
  294.              │        Integral Quality             │
  295.              │        P. O. Box 31970             │
  296.              │        Seattle, Washington 98103         │
  297.              │        (206) 527-2918             │
  298.              │                         │
  299.              ├───────────────────────────────────────┤
  300.              │                         │
  301.              │    LISP/88 ($49.95)             │
  302.              │        Norell Data Systems          │
  303.              │        3400 Wilshire Blvd.          │
  304.              │        P. O. Box 70127             │
  305.              │        Los Angeles, California 90010    │
  306.              │        (213) 257-2026             │
  307.              │                         │
  308.              ├───────────────────────────────────────┤
  309.              │                         │
  310.              │    muLISP-83 ($250)             │
  311.              │        The Soft Warehouse             │
  312.              │        P. O. Box 11174             │
  313.              │        Honolulu, Hawaii 96828-0174      │
  314.              │        (808) 734-5801             │
  315.              │                         │
  316.              └───────────────────────────────────────┘
  317.  
  318.  
  319.  
  320.  
  321.  
  322.              ┌──────────────────────────────────┐
  323.              │ File Name:  ██     lisp1.txt  ██    │
  324.              └──────────────────────────────────┘
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340. 
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350. ,Tû%───┐
  351.              parentheses,  the  Lisp  driver  can  be redefined to
  352.       provide it. (This was done for the Logo syntax.)
  353.  
  354. ┌──────────────────────────────────┐
  355. │ Lisp on the IBM PC           │
  356. └──────────────────────────────────┘
  357.  
  358.            Several    Lisps  are currently available