28

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?

Pillsy
  • 9,781
  • 1
  • 43
  • 70
Orm
  • 507
  • 6
  • 13
  • CLISP is just a standards-compliant (ANSI, to be specific) implementation of LISP. – Matt Ball Nov 11 '09 at 16:41
  • Ok, so then that is not what I am looking for. I need to know if there is an implementation of Lisp to be used as a scripting language. – Orm Nov 11 '09 at 16:44
  • 3
    You must hate your users if you want them to be using lisp as an interface to your framework. – stimms Nov 11 '09 at 17:06
  • 4
    @stimms, you mean, like emacs? ;-) – P Shved Nov 11 '09 at 17:14
  • CLISP does not just stand for Common Lisp; it's a specific free software implementation of Common Lisp. – Pillsy Nov 11 '09 at 17:16
  • 2
    @stimms, yes giving the users you hate some proper tools will certainly mean spending less time listening to their whining about the system – wentbackward Nov 14 '09 at 02:13
  • My reasoning is this. Lisp is a olanguage that was originally developed for AI research, so naturally I thought it would lend itself well to a project such as a game engine (which is my project) in order to make extremely intelligent AI. – Orm Nov 14 '09 at 20:24
  • I believe it will be even more useful for interactive development and tinkering (but developing AI algorithms in it should be fun too) – Daniel Kochmański Jan 23 '16 at 17:02
  • This is an excellent question. Questions like how do I set a variable are the norm here, so a general question like this seems out of place. Questions about general approaches to architecture are very important. While opinions may exist, that in of itself is not disqualifying, since any code writing requires an opinion of the correct approach. I’ve googled about for this very question and finally, having discovered the terms “lisp as an embeddable system” did I finally find the right links. This stackoverflow question is very high on Google search results. – kd4ttc Oct 10 '21 at 18:22

9 Answers9

30

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
  • 9,781
  • 1
  • 43
  • 70
16

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.

  • 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 Nov 12 '09 at 04:51
  • You hardly ever need the whole of Common Lisp, this is pure hyperbole. Scheme is *very* barebones in comparison. – Leslie P. Polzer Nov 12 '09 at 08:22
9

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.

Leslie P. Polzer
  • 2,998
  • 21
  • 18
6

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
  • 546
  • 3
  • 11
  • Interestingly I actually implemented my own basic lisp environment for embedding and embedded devices: https://github.com/wentbackward-org/lisp_mu – wentbackward May 18 '19 at 16:06
5

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

James McMahon
  • 48,506
  • 64
  • 207
  • 283
Jeff Foster
  • 43,770
  • 11
  • 86
  • 103
3

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
  • 7,547
  • 2
  • 28
  • 33
1

Since it is not a Lisp, Fuzuli has a syntax similar to Lisp. It is easy to integrate it to C++ applications. The official site is http://www.fuzuliproject.org

Another one is newLISP at http://www.newlisp.org/ and it is also not a Lisp but very close to Lisp.

jbytecode
  • 681
  • 12
  • 29
  • 1
    He did ask for Lisp but maybe those would work out better for him. Is there any advantage to those over something like ECL or GUILE? – Austin Henley Oct 10 '12 at 20:13
  • As the main developer of Fuzuli, I can't fairly be objective but I can surely say that it is light-weight and it has a steeper learning curve, in addition, the speed can satisfy the need of a scripting language in an application. Trying the online examples in [link](http://www.fuzuliproject.org/index.php?node=tryonline) may give an idea for notation, language and speed. – jbytecode May 14 '13 at 17:34
  • @jbytecode I've looked at Fuzili and it seems to be a challenging project. But really, GPL nowadays is absolutely inappropriate for library (we talk about embedding). – Yury Dec 24 '13 at 11:33
  • 1
    ok you're right. We will change the license to LGPL. – jbytecode Jan 09 '14 at 12:24
1

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
  • 74,053
  • 25
  • 135
  • 175
  • 1
    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 Nov 12 '09 at 04:52
  • 1
    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. – Leslie P. Polzer Nov 12 '09 at 08:27
  • @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 Nov 12 '09 at 13:45
  • @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 Nov 12 '09 at 13:49
  • @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 Nov 13 '09 at 18:11
-2

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
  • 39,638
  • 28
  • 112
  • 212
  • 1
    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 Nov 11 '09 at 17:27
  • Clisp is a specific implementation of ANSI Common Lisp; there are a large handful of other implmentations of the same standard language. – Pillsy Nov 11 '09 at 17:31
  • @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 Nov 11 '09 at 17:54
  • 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 Nov 11 '09 at 19:57
  • 1
    You haven't really given reasons for avoiding Common Lisp. For example CLISP, one implementation (or VM) of Common Lisp is about 5MB. – Leslie P. Polzer Nov 12 '09 at 08:24
  • One argument in favor of using a (Common) Lisp and not some other esoteric language is time management. Before I would decide to learn some niche language like lua or guile or whatever, which I might never use elsewhere, I'd rather invest my time into learning something which can be used in multiple scenarios. So, in that sense, I consider Common Lisp the better choice. Especially, if you are also looking for a language for rapid prototyping, which IMHO is a perfect field to use Common Lisp in. – BitTickler Nov 10 '20 at 09:11