I'm trying to choose between groovy and beanshell, I need one that is in active development, is moderately fast, can access/interpret java code and support restriction to which java classes it can access in my internal code. I'm not sure if beanshell开发者_StackOverflow中文版 is still in active development. Please advice me.
Thank you.
Looking over the beanshell.org archives, it looks like it hasn't been under really active development since 2005. The developer mailing list hasn't had any traffic since January 2009. It's possible that the work has moved elsewhere, of course, but I can't see any obvious destinations...
Groovy is definitely under active development.
(Disclaimer: as someone involved in the Groovy in Action book, I have a certain amount of bias... but I don't actually use Groovy on a regular basis; it's not like I have an axe to grind :)
Below are the differences i found between groovy and beanshell
I would prefer groovy for my development as its serves my purpose wherein it can execute a script written in beanshell.
Anyways below are the observations i found when i evaluated Groovy 2.0.0 agains Beanshell 2.0b4
Both these scripting languages has syntax similar to Java.
Groovy
- Groovy engine can run a script written for beanshell
- Execution environtment is java 1.5 . developed on JDK1.5
Supports Generics and collections with generics. Also suports raw types eg> ArrayList str = new ArrayList()
Supports calling methods with variable arguments eg. method(int...i)
- Supports primitive data types like int to assign 4 byte hexa-decimal values eg. int i = 0x80018000;
- The syntax for array initialization is bit dffierent from java eg. In java, array is initializzed as int[] array = {1,2,3}; In groovy, its is done as int[] array = [1,2,3];
- Supports for loops and for each loops etc
BeanShell
- Beanshell cannot run the script written for groovy as it is based on JDK1.4. so no generic features
- Execution environtment is 1.4 or more but doesnt support generics
- Doesnt support generics. only raw types are supported
- Doesnt support writing a method with variable argumnets or calling a method with variable arugments
Doesnt support assinging certain hex decimal values to the primitive data types eg int i = 0x80018000 throws an exception from the beanshell interpreter saying the size is big A BigInteger is to be used in this case which is again tedious as we have to do something like this BigInteger i = new BigInteger("0x80018000");
This problem occurs even if we declare long i = 0x80018000
- Syntax for array initialization is similar to java.
- Supports for loops and for each loops etc
It appears that Beanshell is under development lately and will be integrated into J2SE at some point. I would vote for Beanshell over Groovy, the most important reason being that it is a bit more straight forward instead of having the learning curve of trying to learn all of Groovy's unique syntax, making it almost like learning a new language.
精彩评论