This is an evaluation of several Java scripting langauges for potential use in ALP. The main requirements for such a scripting language are:
The following scripting languages were evaluated:
Many other languages exist. See http://grunge.cs.tu-berlin.de/~tolk/vmlanguages.html. For a discussion of why scripting languages are important, see http://www.scriptics.com/people/john.ousterhout/scripting.html.
JPL - Java-Perl Lingo - is an integration of Perl 5.0 with Java. It is not a pure Java application. Basically, the standard Perl C library is integrated with Java through the JNI, Java Native Interface. As such, it is more interesting from the point of view of an existing Perl application, rather than an existing Java application. Thus it was not considered further.
Jacl is an implementation of TCL in Java. It is a pure Java application written in about 12,000 lines of Java. Examples and documentation look adequate.
Unfortunately, after down loading the application and following the installation instructions the interpreter could not be started. Presumably, this is not hard to fix, but Jacl was not evaluated further.
JPython is an implementation of Python in Java. JPython is a dynamic object oriented language that uses indentation to minimize syntax. In JPython, Python code is compiled dynamically into Java byte codes and executed by the Java virtual machine. JPython can be used to write Java applications and applets. JPython installs and runs easily. There is adequate documentation. JPython is written in 19,000 lines of Java code.
Creating Java objects in JPython is generally straight forward. However, sometime type conversion issues can make invoking the right Java method tricky. Invoking the JPython interpreter from Java is straightforward.
Here is a simple example of creating a frame with a button. When the button is pressed, the Python exit function is executed.
from pawt import swing
import java
def exit(e): java.lang.System.exit(0)
frame = swing.JFrame('Swing Example', visible=1)
button = swing.JButton('Close Me!', actionPerformed=exit)
frame.contentPane.add(button)
frame.pack()
|
SILK is a Scheme dialect written in Java. It was designed to be a compact interactive language suitable for applet development. It has been used to teach several college courses.
SILK is well integrated with Java and was written in less than 4,000 lines of code. Scheme source code is compiled into threaded code objects which are executed. Scheme's uniform syntax and macro facility makes it ideal as an embedded scripting language.
Here is an example of SILK code that corresponds to the JPython example above.
(import "javax.swing.JFrame") (import "javax.swing.JButton") (import "java.lang.System") (import "elf.Listen") (define (exit e) (System.exit 0)) (define frame (JFrame "Swing Example")) (define button (JButton "Close Me!")) (addActionListener button (Listen.actionPerformed exit)) (add (getContentPane frame) button) (pack frame) (setVisible frame #t) |