Declarative Languages
Lecture #1

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:

Lisp and elements of style.

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.

(administrative interlude)
1.3 Administrative: Software

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

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:
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 ;
a similar repreesntation is also available on the Franz site at

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

Other books which may be useful for reference / background reading are Two books of note on CLOS (the Common Lisp Object System) are In general, be wary of any Lisp book which does not explicitly apply to "Common Lisp".

 (end of administrative interlude)

1.6 Main features of Lisp

Why use Lisp? Because it is

It offers (see also It is particularly suitable for applications which are Examples of real life applications include: 1.7 Practical Session - Familiarity with LispWorks

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.


A separate sheet is available listing a few of the most useful key bindings. Please ask if you suspect there should be a keyboard shortcut for some frequent gesture, but you don't know what it is.

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

We are using a free software here. To be more precise, this is a free edition of a commercial product. The vendor has limited a few aspects of the software, in particular: You will be warned before you hit either limit. I recommend that you save your work and quit the image very soon after receiving the warning, because if either of the above limits are actually exceeded, then the image will halt abruptly and you will have no opportunity to save any work.

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

1.9 Early mistakes
Nick Levine
last modified 2001-09-03, URLs updated 2003-06-23
Copyright (C) Nick Levine 1999-2001. All rights reserved
$Id: // $.