Transcript LISP

By Alex Stephens
and Cody Owen
History

 LISP was designed by John McCarthy of MIT in
1958; it is the second-oldest high-level programming
language in widespread use today.
 It began as an algebraic list processing language for
artificial intelligence, which is where it got its name
(LISt Processing).
 Steve Russell coded the first LISP interpreter. It was
based on the LISP function eval.
 Tim Hart and Michael Levin were the writers of the
first successful LISP compiler. It was written in LISP.
Who is using LISP?

 GIMP – The GNU Image Manipulation Program
 GIMP is a popular free graphics editor. Scripting in
GIMP is written in Scheme, a LISP dialect.
 Mathematical Systems, Inc
 Their Car Crash Database System, written in Allegro
Common Lisp, “lets engineers browse… data about car
crashes to design safer cars (used by Honda).”
 GigaMonkeys Consulting
 Software development and consulting. Owned by
Peter Seibel, writer of Practical Common Lisp.
What is LISP?

 LISP is a multi-paradigm programming language
with a focus on the functional paradigm.
 It was the first homoiconic programming language;
the primary representation of programs is also a data
structure in a primitive type of the language itself.
 It was the most widely-used language in artificial
intelligence until the 1980s.
 Most LISP implementations provide both a compiler
and an interpreter.
Dialects of LISP

 LISP has spawned dozens of dialects since the
original LISP 1 implementation.
 As of today, there are two widely-used dialects of
LISP, Common LISP and Scheme.
 Both Scheme and Common LISP fully support firstclass functions, unlike many earlier versions of LISP.
 Scheme is a relatively small language with a more
functional flavor than Common LISP.
 Common LISP is much larger and has a large
number of data types and structures.

 Pure LISP is another dialect of LISP, which, as
indicated by its name, is purely functional.
 A few more dialects:
 LISP 1.5 – the earliest widely distributed version
 MacLisp – an influential predecessor to Common LISP
 Clojure – a recent LISP which encourages functional
programming
 Emacs Lisp – a LISP used by Emacs text editors
 Franz Lisp – its name is a pun
Syntax/Semantics

 In the original LISP, there were two fundamental
data types, atoms and lists.
 Atoms are either symbols or numeric literals.
 Lists are sequences of atoms and other lists.
 Lists are stored internally as singly-linked lists.
These lists are groups of linked pairs; the first
element of the pair is a datum, which may be another
list or an atom, and the second element of the pair
points to the rest of the list.
 The elements of a list in LISP are separated by
whitespace, and enclosed by parentheses.

 Everything in LISP is written as expressions, which can be
evaluated to a value. There is no distinction between
expressions and statements. Both of the following
expressions are valid and return the same value.
(if test (+ i 1) i)
(+ i (if test 1 0))
 Statements, since they are expressions, only terminate by
a closing parenthesis.
 Semicolons are used for single-line comments.
 #| block comments can be nested #| a comment |# |#
Example Code

 (defun hello ()
“Hello, world!”
)
 (defun factorial (n)
(if (= n 1)
1
(* n (factorial (- n 1)))))

 (lambda (x) (+ x 1))
 The lambda operator creates a function. Its first
operand is a list of arguments to the function. Its
second operand is the expression to which the
function evaluates.
 The above example represents a function which
increments a single argument by 1.
 ((lambda (x) (+ x 1)) 6) evaluates to 7.
Readability

 Pros:
 Orthogonality and simplicity – everything in LISP is
done by using functions calls.
 Cons:
 Polish notation (operators are in front of operands) can
be confusing.
 Unlike many other languages, semicolons begin
comments rather than concluding statements;
 Parenthesis stacking is notorious in LISP for causing
readability issues.
Writability

 Pros:
 Using the interpreter makes writing much easier.
 More complex dialects like Common LISP features
many useful built-in functions.
 LISP is homoiconic, allowing easier
metaprogramming, writing programs that manipulate
other programs.
 Cons:
 Same issues with readability affect writability. Mostly:
Lots of Irritating Superfluous Parentheses (LISP)
Reliability

 Pros:
 Type checking and good error handling enhance
reliability.
 Cons:
 LISP has very little security; functions can alter
themselves as well as other functions.
 Aliasing negatively impacts reliability.
 Problems with readability and writability, specifically
parenthesis stacking, affect reliability indirectly.
Cost

 Pros:
 The interpreter allows for easier debugging.
 LISP runs on multiple platforms.
 Cons:
 Many programmers are relatively unfamiliar with
functional languages, or the awkward notations which
LISP uses. As a result, training could be expensive.
 Most implementations of LISP which are in
commercial use are somewhat costly commercial
versions of LISP, such as Allegro Common Lisp, which
costs at least $600.
Sources









http://en.wikipedia.org/wiki/Lisp_(programming_language)
http://www.csci.csusb.edu/dick/samples/lisp.syntax.html
http://www.cs.uwf.edu/~eelsheik/pl/lisp/evaluation.html
http://www-formal.stanford.edu/jmc/history/lisp/lisp.html
http://www.gimp.org/tutorials/Basic_Scheme/
http://www.paulgraham.com/diff.html
http://www.wbricken.com/pdfs/02teach/03ai/03-lisp-comments.pdf
Concepts of Programming Languages. 9th Ed. Sebesta, Robert W. 2010.