Newbie suggestion

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Newbie suggestion

Lenny Gray
It is not obvious (is it even stated?) in the manual that compiled classes
can be loaded into and run _at_full_JVM_speed_ under bsh. On first reading,
I wasn't encouraged by a review "Choosing a Java scripting language: Round
Two" <>
that said "BeanShell is not as fast as the quickest of the interpreters, but
the 2.0 release supports loading of ordinary Java source" ending with "If
performance is not the single most important criteria for your scripting
interpreter and you want to write Java scripts, look at BeanShell."

After having trouble getting it to do so, I began to doubt that it did,
as various wording throughout the manual seemed to be carefully hinting
that it didn't -- eg: "Since BeanShell can run in the same Java virtual
machine as your application, you can freely work with real, live, Java
objects -- passing them into and out of your scripts" and "With version
2.0 BeanShell becomes a fully Java compatible scripting language.
BeanShell is now capable of interpreting ordinary Java source and
loading .java _source_ files from the class path."

When I finally got a compiled speed test:

> public class HowFast {
>    public int looping (int x) {
>       int  i, j, s = 0;
>       for (i=0; i<x; ++i)
>          for (j=0; j<i; ++j)
>             if ( 3*j == 2*i )
>                ++s;
>       return  s;
> }}

to run with:

bsh % addClassPath ("c:/dir");  //yes, I'm mostly a PC kind of guy
bsh % h = new HowFast();
bsh % print (h.looping (30000));

I'm definitely pleased, but I think an example such as this, for
unit testing, would be an almost mandatory addition to the manual
for newbies such as myself, an appropriate place being page 10,
after "Scripted Methods" and before "Implementing Interfaces".

- Lenny Gray -

SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement *
Beanshell-users mailing list
[hidden email]