Purpose: To introduce the course, give background, and deal with various administrative issues.
1.1 What is a declarative language?
A declarative language is a language in which you describe the problem you are working on and the computer decides how to solve it. Lisp and Prolog are declarative languages.
On the other hand a procedural language is a language in which you tell the computer what to do. The machine will then do what you tell it and you hope that what it tells you is the answer to the question you wanted to ask. Pascal is a procedural language.
These definitions should be treated with the deepest suspicion. They claim to partition all programming languages into two discrete sets: either 100% abstract or 0% abstract. In practice, no language (with the exception of assemblers) fits into either of these categories - they all lie somewhere between the two extremes. However, there's no denying that some languages permit and encourage a higher level of abstraction than others, and that Lisp and Prolog are more abstract than - say - Pascal or C.
One aim of this course is to convey the extent that abstractions can take the agony out of programming. We will illustrate it with examples written in Common Lisp (and the second course aim is to teach Lisp). And even though in years to come you may not always find yourself at liberty to write all your applications in Lisp, many of the concepts covered here apply equally to lower level languages. Lisp encourages good programming style, but having learned about style there's no excuse not to apply it elsewhere. Therefore, we will attempt not to mention the word declarative too often, and will think of this course as more properly titled:
1.2 Brief history of Lisp
Lisp (the acronym stands for LISt Processor) is the second oldest programing language still in use (after FORTRAN), invented by John McCarthy at MIT in 1958. For many years it could only be run on special purpose and rather expensive hardware, such as sold by Xerox, Texas Instruments and Symbolics. In more recent years implementations have appeared on stock systems: initially on unix workstations but more recently on PCs. Nowadays, you cannot buy a PC which is too "small" to run a Lisp system.
Until the mid '80s Lisp was more a family of dialects than a single language. In 1986 an ANSI subcommittee was formed to standardize these dialects into a single Common Lisp, the result being the first Object Oriented language to become standardized, in 1994. Common Lisp is by no means the only dialect still in use, or even the most widespread. But it is the most powerful and has the advantage that once you understand Common Lisp it is easy to adapt yourself to weaker dialects.
Of the Common Lisp vendors, only two major players remain on the field: Xanalys (business formerly run by Harlequin) and Franz. (Many other, less commercial, implementations do exist alongside them.) Both companies distribute "Personal Editions" of their lisp products, for use on Windows 95 / 98 / NT and on Linux platforms; these are all full implementations of the Common Lisp standard, aimed in particular at the academic community, with certain restrictions to encourage professionals to purchase the real thing.
This lecture course used the Personal Edition of Xanalys' LispWorks
for the Windows operating system for its practical lab sessions. You
could use this or any other (full implementation of) Common Lisp for lerning
purposes, though I strongly recommend either Franz or Harlequin, and you
can do so on the operating system of your choice. Visit
http://www.franz.com/downloads/
and
http://www.xanalys.com/downloads/
The downloads are not small. For example, LispWorks downloads as two
10 MB files. Another useful source is the
BURKS CD.
1.4 Administrative: Sources of information - online
The best starting point is without doubt the web site of the Association
of Lisp Users:
http://www.lisp.org/.
You will find all manner of useful resources here: books, tutorials,
papers, history, software, background material.
An HTML representation of the Common Lisp specification, known as the
HyperSpec
will be found at
http://www.lispworks.com/reference/HyperSpec/Front/index.htm
;
a similar repreesntation is also available on the Franz site at
http://www.franz.com/support/documentation/6.0/ansicl/ansicl.htm.
If you are into newsgroups then try news:comp.lang.lisp. If you are totally stuck on some concept you may post there (and you will generally get a useful answer or ten) but you if you are a student asking for help with a formal assigment then you must make this clear in your posting.. If you fail to do this then (a) you will be flamed by other readers for what is considered to be a breach of netiquette and (b) you will have me breathing down your neck (I subscribe to this group).
1.5 Administrative: Sources of information - books
The recommended book is
(end of administrative interlude)
1.6 Main features of Lisp
Why use Lisp? Because it is
1.7.1 Starting Lisp
The software we are running at Anglia is the Personal Edition of LispWorks version 4.1.0. This is free software from Xanalys. The product runs on Windows 95, 98 and NT 4.
To start a lisp session, select the following item under Programs on your Start menu:
Harlequin LispWorks 4.1 \ Personal Edition \ LispWorks
There will be a short delay while the lisp system initializes itself. You will eventually be left with three windows on-screen. On top is a nagware window titled "Upgrade to LispWorks Professional Edition" which you need to dismiss by clicking on "OK". Underneath that is a small window (the "podium"), titled "LispWorks Personal Edition 4.1.0" and - somewhat larger - a window titled "Listener 1". This last will be referred to in these notes as "the listener".
Do not attempt to close the podium; you might lose your entire lisp session. Note that if you iconise the podium you will find all your other lisp windows also iconised. (If this happens simply bring back the listener from the task bar.) Hint: just leave the podium alone.
Bring the listener to the top and make it large (e.g. maximize it).
Incidentally, if you succeed in accidentally closing the listener, you can create a new one by going to the Tools menu on the podium.
1.7.2 On-line documentation
LispWorks comes with complete on-line documentation, in html form. This includes an html representation of the ANSI specification for Common Lisp. The full documentation takes up roughly 200 MB on the hard disk and it may not be possible to for me to install it on the machines available for these practical sessions. If this turns out to be the case and if you wish to access on-line documentation during these sessions, you will need to purchase and bring with you a copy of Xanalys' "Software tools sampler" CD. To use it, simply insert the CD into your machine and kill any application which autostarts on you. The lisp software will then be able to access documentation as-and-when you need it.
To access the documentation, either go to:
Harlequin LispWorks
4.1 \ Personal Edition \ Browsable Documentation
under Programs on your Start menu, or select
Help \ Manuals ...
on the podium, or use the editor key binding Ctrl+Shift+D.
1.7.3 The LispWorks Editor
The editor is driven by EMACS-style key bindings. These are not the same as standard Windows bindings, and there are some subtle differences in the style of interaction. In particular be aware that selecting a swathe of text and then typing will not delete that text.
Roughly:
The listener, which you will use for direct interaction with the lisp system, uses the editor key bindings plus some extras.
1.7.4 Pauses and limitations
You will occasionally note that the system is somewhat sluggish in its response. This can be for one of two reasons
In any case, you can restart lisp immediately, reload your work, and continue where you left off.
1.7.5 When You Get Stuck
Visit the Agony Corner
1.8 Suggested activity