I am writing a graphics application in Java. Eventually I would like to build in a scripting language so things are programmable. Which language library do you recommend?
Likely suspects are:
Less likely candidates are:
The target audience are probably not hardcore programmers, so less arcane language is preferred. My guess is that JavaScript is more acceptable by them even with its quirks just because they've seen it more.
Lua seems to be popular in C/C++, but at least LuaJava requires additional .dll/.so, which makes deployment complicated.
EDIT: PhiLho wrote that there's a Java implementation of Lua called kahlua.
Related questions:
If you wanted to go all out you could utilize scripting for the Java Platform as defined by JSR 223. Taking that approach would allow the application to utilize any language that has a conforming script engine.
if the target audience is "no programming skills...." choose jython (python) it is easy to learn. (my 7 year old daugther learned it very quick)
Bruce Eckel made a chapter with jython in "thinking in java".
at the danger getting a "down-vote" python is easier as BASIC :-)
Java 6 already has javascript available as a JSR 223 scripting language, out of the box.
You can use RelProxy - Java, it provides real and pure Java as a scripting language, including shell scripts made with Java, thanks to its compilation on the fly. Because the Java "script" is executed sharing the launcher ClassLoader, integration is straightforward.
I'm currently looking for a library that will allow me to use Java objects and methods from Lua scripts.
My first idea was to use LuaJava too, but as I want this to work on Linux, Mac and Windows, I was put off by the fact that it uses a compiled lib in addition to the Java stuff. Only Windows pre-compiled binaries are available, and I'm not an expert on Mac, so I tried to find something in pure Java, and I found this: http://sourceforge.net/projects/luaj
It seems to implement the C API described in the Lua doc, as well as the API from LuaJava.
The project seems really advanced, there are examples of Swing calls from Lua (!), and they worked on my Linux box. But oddly, mailing lists, forums and documentation are really sparse.
I'm gonna try this on Windows and Mac, too. Hope it works.
Kahlua has been mentioned, but it's only targeted at J2ME, that's why it lacks some parts of Lua. I think there's a project called Mochalua that has the same goals.
LuaJ, on the other hand, comes in two versions, one targeted at J2SE that implements everything (coroutines, too), and one targeted at J2ME, which lacks 2 or 3 libs I think (including the LuaJava stuff, which needs reflection).
I just read Steve Yegge's The Universal Design Pattern. The article is on much broader topic than just embedded scripting in Java application, but since the author writes a Java application that allows scripting (using Jython), there are insightful points I found interesting.
I agree with him on narrowing down to JavaScript and Lua.
I personally prefer JavaScript on Java platform. The population of the user base is larger. As Yegge puts it, it is "the world's most misunderstood programming language," but the amount of resource available on the language is a plus. Rhino seems to a matured beast.