[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Aug 3 23:52:14 1999 
Subject:Re: Why are there so many versions of lisp ? 
From:Aaron Sloman See text for reply address 
Volume-ID:990804.01 

[Originally posted to comp.lang.lisp as a followup. I intended to
cross-post to comp.lang.pop, but mistyped.... so I'm doing that
separately.]

Craig Brozefsky <craig@red-bean.com> writes:

> Date: 31 Jul 1999 20:15:59 -0500
>
> rurban@xarch.tu-graz.ac.at (Reini Urban) writes:
>
> > I asked:
> > >> where to put poplog?
> >
> > joswig@lavielle.com (Rainer Joswig) wrote:
> > >What part of it?
> >
> > that's what i wanted to avoid :)
> > in the announce by Aaron Sloman 4 major languages were mentioned:
> > Pop, CL, Prolog, ML, even more than Erlang.
> >
> > i thought i would get a cheap classification without having to download
> > another 25megs or reading tons of docs of just another functional
> > language without parens. for me it looks like erlang but who knows...

I presume that by "it" you are referring to Pop-11, not Poplog?

Craig answered this, but I thought I could usefully expand on some
parts of his answer, and say a bit more about how Poplog Common Lisp
fits into Poplog.

[Craig]
> Poplog is an IMPLEMENTATION, not a language.

Or one could call it a "runtime language toolkit".

I.e. there are some fairly general tools, which are pop-11 functions,
for building incremental compilers which compile code to a moderately
high level, machine independent and language independent, Poplog Virtual
Machine (PVM).

Those tools are used to define incremental compilers for Pop-11, Prolog,
ML, and Common Lisp. (You don't have to have all of those compilers in
the running system, apart from the core Pop-11 stuff. The other
compilers are just optionally loadable libraries, though they can be
pre-compiled in saved images.)

The same tools could be used to define incremental compilers for other
languages. Someone may try Java one day....

The same compiler tools are available to the Pop-11 programmer, so the
language Pop-11 is indefinitely extendable. Hence there can be no
defined syntax for it, there is no standard parse tree for it, and it is
more or less impossible to define totally general source-code-analysing
tools for Pop-11 programs. (I guess you could define something that
analysed code by simulating the compiler and then anlysed the PVM
instructions generated.)

This is unlike Lisp: macros allow you to extend the language, but all
the extensions must expand into legal Lisp. In Pop-11 all that is
required is that the extensions compile to the poplog VM, which imposes
very few constraints.

This feature has been used by several extension to Pop-11, notably
objectclass, which added CLOS-like functionality with a range of
syntactic extensions.

Besides the "high level" PVM, there is a lower level virtual machine,
also language independent and machine independent, the Poplog
Implementation machine (PIM), and a compiler from PVM to PIM.

For incremental compilation a machine specific compiler compiles from
PIM to the host machine's instructions, and builds executable machine
code functions, stored in the heap.

For rebuilding the Poplog system, and for porting to a new machine, that
back-end compiler is replaced by one which generates assembler files
(and other important files defining the runtime system, e.g. the system
dictionary) for the target machine.

For Poplog system builders there is a special extended dialect of Pop-11
(Syspop) which includes C-like pointer manipulation, and other features
which allow very efficient code to be written. (E.g. the Poplog garbage
collector, which is very fast, is written in this dialect.) But those
extensions are not available for the ordinary programmer in
the incremental compiler. You can see a sample of this dialect in

ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/src/master/C.all/src/getstore.p

where the procedure Sysgarbage is defined. I believe the code there runs
about as fast as code you could write in C, though it is all Syspop.

From time to time there is talk of defining a more constrained sub-set
of Pop-11, e.g. as a systems programming language. I suspect it could
diverge into two main dialects: one for commercial and systems
programming and one for AI/Cognitive science teaching and research.

Anyone who wants to see what is involved in defining an incremental
compiler for a new language can look at the main code for the lisp,
prolog and ML compilers, in these three directories.

    ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/src/master/C.all/lisp/src/
    ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/src/master/C.all/plog/src/
    ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/src/master/C.all/pml/src/

[Craig]
> It is a system which is primarily based on Pop11, but whose VM and
> compiler are capable of handling Pop11, prolog, ML and Common Lisp,

That is correct. I hope my expansion above makes clear that there are
two VMs and three sorts of compilers at run time:

1. High level compilers, e.g. Lisp, or Prolog to PVM)
    HLL -> PVM
2. Intermediate compiler
    PVM -> PIM
3. Back end compiler (code generator).
    PIM -> Machine code.

For rebuilding the system all three compilers are run in a slightly
modified form:
(a) to cope with Syspop extensions in the source code
(b) to do extra optimising,
(c) to produce output files that can be used to build Poplog from
scratch, using an assembler and linker for the target machine.

[Craig]
> and I believe there is Scheme support (tho not distribution with
> poplog normally).

I think Robin Popplestone (the original inventor of the Pop language
family) at UMASS has a version of Scheme implemented in Poplog which he
has been using for teaching. He is out of contact at present, but I hope
that when he returns he will donate it to the freepoplog ftp site.

> These languages can interact with varying degrees,

In particular the languages share the procedure call stack, the heap,
and many data-types such as lists, integers, bigintegers, ratios, etc.
have exactly the same implementation for all of them. Prolog has some
special support in the Poplog VM, including a continuation stack, and
the "trail" mechanism. Details are in
    ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/doc/popref/prolog

This sharing does mean that certain optimisations that a "pure" language
compiler would use are unsafe. E.g. the prolog compiler cannot tell what
Pop-11 procedures might have done with some prolog lists, so Poplog
prolog cannot do all the store management tricks a pure Prolog system
might do.

Another problem is that booleans in Pop-11 are a distinct data type,
with two elements, true and false (though conditional expressions treat
anything non false as true) whereas in Common Lisp (sigh...) there is no
boolean data type.

So false in Pop-11 and nil in lisp are distinct entities, though nil in
lisp and in Pop-11 are identical. This adds a slight overhead to Common
Lisp in Poplog, compared with a "pure" common lisp.

(In the original Pop2 language developed in Edinburgh, 0 was used as
false, as in many other languages. At Sussex we decided that was a
design error, around 1975, and introduced the two booleans, when
Pop-11 was first implemented to run on a PDP11/40computer.)

An interesting interaction is that Pop-11 includes a lightweight process
mechanism, described in
    ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/doc/popref/process

The Pop-11 procedures creating and manipulating processes can be applied
to prolog, lisp or ML. Thus, for example, you can have concurrent prolog
or Lisp programs for free within a poplog process. (I don't know if
anyone has used that.)

> and you can compile more than one language into an image.  It is a
> very open and inclusive system in general, and is very well
> documented.

I think the documentation for system builders is not as good as
documentation for users. I hope that can later be remedied.

> It has very litte in common with Erlang, at the language, or the VM
> level.  Nor does Pop11.  IMO, Pop11 is much more like an open stack
> Lisp,

Pop-11 shares much of the power of Common Lisp: both are very rich,
extendable multi-paradigm languages. But there are also interesting
differences apart from the syntax. In particular Pop-11 has much in
common with Forth, because it uses an open stack, and it even supports
two syntactic forms, the conventional prefix syntax and also a postfix
syntax suited for a stack oriented language. E.g. these two are
equivalent in Pop-11 where "." means apply and "->" means "assign to" in
Pop-11:

    f(x, g(y,z)) -> v;        =     x, y, z, .g, .f -> v;
                              =     x, y, z, g(), f() -> v;

which translates into Poplog VM instructions of the form:

    push("x"), push("y"), push("z"), call("g"), call("f"), pop("v").

g presumably takes two things off the stack and puts back N things.
f takes N+1 things off the stack, and puts back one thing.
"->" takes as many things off the stack as required. E.g. the multiple
assignment:

    -> (x, y, z)

takes three things off the stack and assigns the top item to z, the next
one to y, and the third one to x.

The use of the open stack can introduce obscure bugs. It can also allow
very elegant code, e.g. using
    [% ....%]
to surround a loop expression or recursive function call that puts an
arbitrary number of things on the stack will create a list of all those
things.

More usefully,
    {% ... %}
creates a vector of things left on the stack without having to know in
advance how big the vector is.

> with lots of AI niceties built into it, like rule databases and
> pattern matching, and an Algol inspired syntax that is user extensible
> with macros and thru modifying the reader/compiler.

> It has some
> interesting scoping and binding options for the user, because it
> seperates the two issues.

Like Common Lisp, pop-11 supports full lexical scoping (e.g. allowing a
function to return a lexical closure of a nested function), and also
supports dynamically bound global variables (as a special case of its
"dlocal" (dynamic local) mechanism, not unlike Lisp's unwind-protect, I
understand.)

> I really dig it, and it has a killer emacs
> interface.

I believe Brian Logan will shortly introduce a new updated version of
the emacs interface.

> There is your cheap, free even, classification.  Tho do not rush to
> throw poplog into any category you have come across already.  I tried
> to do that and found that poplog is quite original and alien to most
> of what I am familiar with, and IMO, it's excellently executed.

I should point out that Poplog Common Lisp has some missing features
listed in here:

ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/doc/lisphelp/bugs

I don't know how hard they would be to fix, nor how important.

That file doesn't mention that Poplog doesn't have an interpreter: the
incremental compiler is so fast that it was simplest to compile and
execute (totally avoiding incompatibility between compiled and
interpreted code) though sometimes an interpreter might be useful,
especially for debugging. (However, this is an implementation option,
according to CLTL.)

Apologies if I have gone on too long.

> --
> Craig Brozefsky                         <craig@red-bean.com>
> Free Scheme/Lisp Software     http://www.red-bean.com/~craig


Aaron
===
-- 
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk   (NB: Anti Spam address)
PAPERS: ftp://ftp.cs.bham.ac.uk/pub/groups/cog_affect/0-INDEX.html