[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: another take on hackers and painters



Steve Dekorte wrote:
> On Tuesday, May 20, 2003, at 04:36 PM, mcguire@cs.utexas.edu wrote:
> > [1] Yes, sort of: Java's reflection API...
> > [2] ...and it's ugly.  I am actually hoping for something more
> > interesting, from a language with a better type system.
>
> Java can do reflection, but can it really do eval?

It can, if you cheat and use something like BeanShell (www.beanshell.org).
>From the Intro on that site: "BeanShell is a small, free, embeddable, Java
source interpreter with object scripting language features, written in Java.
BeanShell executes standard Java statements and expressions, in addition to
obvious scripting commands and syntax."

The intro also mentions that it "uses the Java reflection API to provide
runtime interpreted execution of Java statements and expressions".

One of the things that reflection makes possible in this case is querying,
access, and manipulation of objects in the host program, so that it operates
like a true 'eval', and not just like an embedded interpreter without direct
access to the host program.

For Java developers, BeanShell can make a pretty logical scripting language.
Type declarations are optional, so it has a scripting language feel that
pure Java lacks.  Since the semantics are still Java semantics, you don't
run into the kinds of issues, such as type translation, that tend to arise
when scripting Java with Scheme, Python, Javascript etc.

Anton