jdrago_999 has asked for the wisdom of the Perl Monks concerning the following question:

Monks -

I'm looking at adding the ability to extend a Perl application via a scripting language. The idea would be to allow definition of logic that should be executed at specific points within a workflow.

I'm hesitant to choose Perl since it is a bit to general-purpose and would end up giving users too much rope to hang themselves with. Inline::Lua and Inline::JavaScript sound good.

I know Lua is becoming a popular choice with game developers for similar applications - that is why I mentioned it.

I would like to expose a handful of variables and functions I define in Perl to the scripting environment.

Thoughts?

Replies are listed 'Best First'.
Re: Preferred Scripting Language to Embed?
by blazar (Canon) on Oct 12, 2006 at 19:57 UTC
    I know Lua is becoming a popular choice with game developers for similar applications - that is why I mentioned it.

    I'm not familiar with game development, but I've heard good comments about Lua, in particular it has been designed as the embedded language of choice for what that if I understand correctly should be the successor to pdfTeX i.e. namely LuaTeX. I didn't even know about Inline::Lua but that definitely sounds as good news. Other than that another neat little language especially targeted at embedding which I personally find to be quite interesting is io, although in this case I see that there's no Inline::io nor Inline::Io, which suggests me that possible connections with Perl are much less explored, but of course I would be glad to be proven wrong.

Re: Preferred Scripting Language to Embed?
by jdporter (Paladin) on Oct 12, 2006 at 20:08 UTC

    Except that Javascript and Lua (and other embedded scripting languages, like Guile and S-Lang) are full-featured, Turing-complete languages, so you don't get any protection against foot-shooting relative to Perl. If you're going to use a "real" language (like any of the above), you may as well choose one which has the simplest, most user-friendly syntax. That would rule out Javascript at least as much as Perl.

    If by "logic" you mean something more declarative than procedural, you could consider Prolog, for which some modules exist: AI::Prolog and Language-Prolog.

    We're building the house of the future together.
      Let me clarify.

      I want a language that allows variable & method declaration, branching (if/elseif/else) loops (for/foreach/while), recursion and simple data structures (scalar, list, hash).

      When I say "logic" I mean "branching, looping, variable-declaration and assignment, method-calls and return values".

      Things I don't want are file- or socket-io operations, sleep() or exit(). Nor do I want the ability to import other modules.

      I would use Inline::WSC and embed JavaScript and/or VBScript but it is only for Windows and the application I am writing is intended for Linux.
        Things I don't want are file- or socket-io operations...I would use Inline::WSC and embed JavaScript and/or VBScript

        As someone who's supporting legacy VBScript apps, I can tell you that it does allow file operations; indeed, one of the first things I wrote for one app in question was a very basic logging tool. I suspect JS, outside of browser sandboxing, allows similar activities.

        Indeed, I support the idea of you sandboxing the scripting language over trying to find a Turing-complete language with the attributes in question. Sandboxing seems to be "the way" to corral such users, esp. since few languages are restricted in the way you're looking for.

        ----Asim, known to some as Woodrow.

Re: Preferred Scripting Language to Embed?
by sgifford (Prior) on Oct 12, 2006 at 22:22 UTC
    If you'd like to allow Perl but are concerned users will do unsafe things, you could try using Safe to restrict what they can do.
Re: Preferred Scripting Language to Embed?
by chromatic (Archbishop) on Oct 12, 2006 at 21:49 UTC

    You could embed Parrot and write your own little language compiler with it.

Re: Preferred Scripting Language to Embed?
by Arunbear (Prior) on Oct 12, 2006 at 22:35 UTC