Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A small embeddable language?

8 views
Skip to first unread message

Anthony

unread,
Sep 9, 2009, 6:39:25 PM9/9/09
to
This may be a bit off-topic, but I thought I would give it a try
anyway. I am interested in the idea of a minimal yet extensible (in a
lispy way) language that can be embedded into a host language simply
by implementing its core (special operators) in that language. This
would be different from something like ECL or embedded python, which
are both embeddable into C or require linking to a C library. These
cannot be embedded in a language or platform that does not support
C. I know C is generally the lowest common denominator but there are
some platforms where C# or ActionScript is all you have, like in XNA,
Silverlight or Flash. It could also be embeddable into Common Lisp,
without using FFI's.

The ideal language for me would be Lisp-like, where the language is
built up from a small set of special operators. And ideally the core
should be so simple it could be implemented in any language within a
day. Does such a language or language specification exist? Maybe
this is Scheme but I am thinking of something maybe even simpler than
that.

If it doesn't exist there must be some minimal core that has been
defined somewhere that I can build upon. For the sake of easy
implementation, perhaps it assumes the existence of a garbage
collector. Maybe the core is just a simple register machine like the
one in SICP?

I am interested in what others think about this.

Thanks,

Anthony

Thomas A. Russ

unread,
Sep 9, 2009, 9:46:04 PM9/9/09
to

You could try SIOD: Scheme in one {Defun | Day}

http://people.delphiforums.com/gjc/siod.html
http://en.wikipedia.org/wiki/SIOD

--
Thomas A. Russ, USC/Information Sciences Institute

Pascal J. Bourguignon

unread,
Sep 9, 2009, 10:15:39 PM9/9/09
to
Anthony <fairchil...@gmail.com> writes:

Nowadays, it's not the memory size that you are concerned with, but
the effort needed to install your lisp language in the alien
environment.

With this in mind, implementing a virtual machine might indeed be the
fastest and easiest way to port a lisp implementation over random
alien languages. That virtual machine may be really simple and not
require more than a couple of hours to implement in any programming
language. Then you just boot a standard, predefined lisp image on
that virtual machine, and you may have fun.

This would give an ultra portable embeddable implementation. Slow,
but it could be used to bootstrap another implementation such as sbcl.

Of course, this might not give the best run-time performance possible
(for this you would want to fine tune a lisp to alien language
translator / compiler (like ecl translating to C, or sbcl translating
to ix86), but if you were after run-time performance you would use a
normal CL implementation anyways.


You could also implement the famous eval function directly in the
alien language, and bootstrap a lisp from it, but this is programming
in the alien language, so you'd need to implement also a minimal lisp
reader in the alien language, not in lisp, so it might not be as fun.

On these "targets", we could count on having integers and strings,
even if some of them mix them in a single kind of values (eg. perl,
bourne shell, etc), and you would have to count on some kind of
vector. So you could define the virtual machine from these basic data
types, integer (fixnums), strings, vectors of integers and vectors of
strings. Choose the primitive operations you want on these data
types. Implement a lisp package exporting them. Implement over it
the other data types you will need for a minimal lisp machine,
characters, strings, symbols, conses, fixnums, vectors, hash-tables,
packages, a garbage collector, etc. You can already do that in lisp,
at least in a simple subset, for which you'd write a compiler later.
So you bootstrap a lisp written in lisp. Once you've got something
usable, you can implement the lisp compiler targetting the small
virtual machine you defined at the beginning. You compile all your
code and package it in a loadable image.

Then you implement the virtual machine in your target alien language,
and you boot your lisp on it.


--
__Pascal Bourguignon__

0 new messages