Hi Andres,
On 16.8.2013 17:40, Andres Navarro wrote:
> I missed this when you sent it. I've just taken a look at the repo,
> and it looks really interesting. I'll have to study it in more detail
> later on.
>
> It would be nice if could you share here your approach, motivations,
Part of the motivation was to have faster interpreter. Until we figure
out how to compile the Kernel Language (if it is possible at all),
all we can do is to speed up the interpreter a bit.
There is definitely room for improvements:
1) the lua garbage collector on top of C malloc(), although robust
and portable, is not a good match for a lisp with lot of
heap-allocated short-lived continuations.
2) klisp spends too much time allocating and deconstructing
argument lists.
3) klisp values take too much space (e.g. 32 bytes for single cons cell),
decreasing efficiency of processor caching.
(Disclaimer: I do not have any rigorous measurements to back these arguments.)
Bronze Age Lisp is faster than klisp for small programs which rely heavily on
interpreted code and function calls. It is not suitable for big programs which rely
on the reader and printer or the numeric tower, I mostly neglected these topics.
I'll write up about the different approaches later.
Try running fklisp.k in Bronze Age Lisp. But note that I also cheat a bit, my
implementation is not as robust as klisp.
> difficulties,
One would think that the language Kernel Report is so simple that
implementation could be very small and easy. I found that this
is not the case, if you write the interpreter in low-level language.
Besides the library combiners, you have to implement and debug at least
- garbage collector
- symbol interning
- equal? and copy-es-immutable, which must work with cyclic structures
- searching guards in continuation tree
- big integers
- s-expression reader and printer
The interpreter will end up surprisingly big. Bronze Age Lisp executable
now approaches 180 kilobytes (stripped).
> successes, etc.
Because of rather primitive design (thats why it is named Bronze Age ...),
the interpreter starts up quickly.
> $ strace bronze-0.2 -e '(exit 42)'
> execve("/usr/local/bin/bronze-0.2", ["bronze-0.2", "-e", "(exit 42)"], [/* 34 vars */]) = 0
> _exit(42) = ?
Try this with any C program dynamically linked with GNU libc.
Best wishes,
Oto Havle.