The Next Lisp:
Back to the Future
©
Dr Mark Tarver, 2009
Lessons to
Learn and my Work with Qi
So what lessons do we learn from all this? I make
about 7, which is a nice magical number.
1.
Dont bet the farm on a cumbersome
language standard that is difficult to change
and replace.
2. Create a standard approach to common
problems like concurrency, threads and OS
calling.
3. Hive off stuff into libraries.
4. Absorb the lessons of programming
development going on around you.
5. Dont get trapped in a phenotype -
whether machine or language.
6. Listen to your critics - particularly
newbies.
7. Learn to communicate.
Now I want to
talk a bit about my own work on Qi. By the way, I
have pronounced it as Q Eye for years
which is wrong. I got the habit from my students.
It really should be chee which is the
Taoist concept of life force. I'm a Taoist and
hope to return to the mountains one day. But
right now I'm here in the world of men and so
I'll continue talking for a while.
Qi began life in the Laboratory for the
Foundations of Computer Science in 1989. It owes
its character from observing the activity with
Standard ML, since the LFCS was the origin of
that particular language. Essentially Qi is a
harmonious fusion of three different paradigms; a
functional one based on pattern-directed list
handling and using sequent calculus to define
types; a logic programming component based on
Prolog and a language-oriented component based on
compiler-compiler technology.
Its a powerful combination and its
not an accidental one. Each component has an
important part to play in the coding of Qi. The
compiler-compiler is used to frame the reader and
writer, the Prolog compiles the sequent calculus
to code and the functional language does nearly
everything else. The result is that the source is
amazingly small - about 2000 lines, but packs a
punch like Bruce Lee who was built on the same
scale.
The idea of Qi was to provide a programming
environment based on CL but with the features of
a modern functional programming environment. In
fact, Qi is ahead of functional programming
design in many of its features. Its generally
efficient, being faster in execution than
hand-coded native CL and has all the features of
the Lisp genotype while being about 3x more
compact for programming purposes than CL. It
comes with a book and a collection of correctness
proofs that nobody reads.
Qi is very powerful, but it is not
computationally adequate as it stands.
Computational adequacy is a term
Ive coined to describe the characteristics
that a language has when it is adequate for the
needs of the programmers of the day. CL was
computationally adequate in 1984 but is not
today. Computational adequacy today means finding
good answers to questions of how to provide
threads, concurrency, FFI, GUI support and so on.
Qi is not computationally adequate because it is
written in CL which is itself not computationally
adequate. Im going to talk about what
Ive been doing to fix that, because it
reflects back on the way that Lisp itself should
go.
The general strategy of Qi development can be
summed up in 6 aphorisms.
1. Grab the
easy stuff.
2. Featurise out differences.
3. Infiltrate don't confront.
4. Isolate the core.
5. The genotype is always more important than
the phenotype.
6. Educate people.
Since Qi is
written in CL, grabbing the easy stuff meant
grabbing the CL libraries and bits of the CL
specification. CLStrings, CLMaths
and CLErrors are all part of the
Qi library and they bring type security to CL
maths, string and error handling. CLHash and
ClStreams are on the way. They are easy pickings.
The combined sum is a lazy week's work.
Parts of the Qi library are not part of CL. Qi/tk
is the biggest. The type theory of Qi/tk is 511
lines of Qi that generates over 200 rules and
axioms of sequent calculus. This in turn
generates over 27,000 lines of Common Lisp. But
its quick. A game program of 561 lines
typechecks and compiles in 5 seconds under CLisp
(1-2 seconds under SBCL). It includes constraint
propagation that allows you to dynamically link
the properties of widgets to each other.
Ive begun to featurise out the differences
between CL implementations; there is one way to
quit, one way to save an image and hopefully one
day, one way to call the OS. Our goal is to make
the Lisp platform invisible; and by
Lisp I'm talking about the Lisp
genotype not the phenotype.
CL is great and Blub is crap has not
worked as a strategy for selling Common Lisp.
People invest years of their life learning Blub
and dont want to hear this message. A
strategy of infiltation is better. The Q
machines are intended as a collection of
machines that cross-compile Qi into any member of
the Lisp genotype. Qi compiles into CL, but Quip
compiles Qi into Python and that already exists.
Clojure, Ruby, Perl are later targets. Qi can be
used to provide optional type security for
untyped languages like Python. The proper
destination for Qi is as a universal
metalanguage. Write once, run anywhere.

|