views:

662

answers:

8

Hey, I've been looking at the possibility of adding a scripting language into my framework and I heard about Lisp and thought I would give it a go. Is there a VM for Lisp like Lua and Python or am I in the wrong mindset. I found CLISP here, http://clisp.cons.org/, but am not sure if this is what I am looking for.

Can anyone point me in the right direction?

+11  A: 

Unless you need the whole of Lisp, you may want to settle rather on a Scheme implementation like Guile which is meant to be incorporated into another program.

Sebastien Tanguy
A prior job of mine had very good success with implementing a Scheme-like language for runtime scripting. (We couldn't just use Guile for memory and performance reasons, but it was basically a subset of Scheme.)
Crashworks
You hardly ever need the whole of Common Lisp, this is pure hyperbole. Scheme is *very* barebones in comparison.
skypher
+1  A: 

Googling a little bit: Common Lisp as an Extension language

But keep in mind that Common Lisp wasn't designed from the ground up to be an extension language, unlike Lua or Guile.

A general advice: try to use an extension language that really makes the work of writing them easier, and remember that mastering Lisp so you can be really productive with it can take quite long (and there are not many people around that can stand so many parens xD).

fortran
Guile is an implementation of Scheme, and Scheme wasn't designed as an extension language either. If you count Guile you should count ECL as well.
Chris Lutz
Lisp languages have the actual benefit of having a uniform syntax which makes them easier to understand and use than languages with traditional syntax.There's no operator precedence or many funny characters that need to be held in your head.
skypher
@Chris, OK, Scheme wasn't designed as an extension language, but it's pretty small, which makes it very suitable to use as an embedded language. On the other hand, Common Lisp is huge. That doesn't mean that it cannot be embedded, but it makes little sense having a "scripting" language as large as CL. I would be something like using Java as "scripting" language... of course it's been done before (I remember the game Vampire: Masquerade now), but I still think both are complex and big enough to be main programming languages on their own, not extension languages.
fortran
@skypher I hope you're joking, because if you ask to any non lisper to decide what is more readable between `(+ 2 (* 5 3))` and `2 + 5*3` I bet the answer would be the second one with probability of 99%. About funny characters, let me recall the quote, backquote, comma, the quote and hash... No, definitively the easiness to understand the code is not what I would call an advantage of using Common Lisp.
fortran
@fortran: I see no joke here. The former evaluates to 17 in every Lisp dialect, while the latter is 17 or 21 depending on which ALGOL-derived language you're using. Except for arithmetic, almost every language is prefix anyway, and most Lisps I've used have a infix-expression function if you really need it. (Besides, how often does a typical program do arithmetic? The higher-level you're at, the less you need it: I see less arithmetic in typical C# code than in Java, both of which have far less than C, even for the same task.)
Ken
+4  A: 

Chicken Scheme is another option for embedding. See here for details of the embeddable api.

Jeff Foster
A: 

Lisp is a family of languages.

Common Lisp is an ANSI standard that is huge. Think C++ huge. Don't use it as a script language.

Unless you are targeting fairly hardcore programmers, Lisp as a scripting language is going to be...er....not well taking. Probably. Lua is likely a better bet as a script language.

That said, a Lisp is fine(technically) for implementing a scripting language.

Paul Nathan
Clisp is not a language, Clisp is an implementation of Common Lisp. Common Lisp is a language and has an ANSI standard. Several applications are using Common Lisp as a scripting language - especially those who need non-trivial extensions, like complex CAD systems.
Rainer Joswig
Clisp is a specific implementation of ANSI Common Lisp; there are a large handful of other implmentations of the same standard language.
Pillsy
Fixed, fixed. yeesh.
Paul Nathan
@Rainer: Yes, non-trivial extensibility would imply that common lisp or similarly sized language would fit the app's needs. It kinda depends. Most applications don't need a full-blown programming language plugin system.
Paul Nathan
The question was about some Lisp VM similar to Lua and Python. Common Lisp implementations like ECL are in that league. If he wants Python, he could use an implementation like ECL as well.
Rainer Joswig
You haven't really given reasons for avoiding Common Lisp. For example CLISP, one implementation (or VM) of Common Lisp is about 5MB.
skypher
+12  A: 

CLISP is just one implementation of Common Lisp. It's a very good implementation, and it does have some support for being embedded in other (C-based) programs, but that's not its focus and it's GPLed, which may or may not be a deal-breaker for you.

You might be interested in checking out ECL. This implementation is specifically designed to be embedded (indeed, the "E" stands for "Embeddable"!), and has numerous features that might be useful to you, including the ability to compile Common Lisp programs to C (as well as providing byte-code compilation and an interpreter).

Pillsy
Since you were the first to recommend it, I marked yours as the answer. Sorry skypher =S
Orm
+2  A: 

There are a couple of easy options.

GUILE is the GNU extension language. It is an embeddable Scheme (dialect of LISP). GPL (naturally).

TinyScheme is a very small, very simple interpreter-based implementation of Scheme. It was successfully used by a malware company to do all kinds of nasty things. It is available in source form, I don't recall under what license(s).

John R. Strohm
+3  A: 

Try Embeddable Common Lisp (ECL).

http://ecls.sourceforge.net/

It's targeted at embedding and you get only the parts of Common Lisp linked that your scripting language needs.

skypher
A: 

A Lisp is a good choice for an embedded language. Many people believe Lisp is hard but the syntax is relatively light, especially for non-programmers. There is essentially the prefix notation and that's it. Precedence rules are always unambiguous. Function names and variable names can be the same. You're pretty much free to use any characters you like for fun and var names.

With Lisp you can bend the syntax to your liking; the users do not have to learn common lisp. It is easy to extend and to provide, simpler facilities, such as expressing business rules or extracting data from files.

I guess my point is that the power and complexity of say Common Lisp, enables the provision of simple, domain specific constructs to the end user. Many other embedded languages will mean those users learning the intricacies of that language.

wentbackward