One of the most useful things I've come across for Java is Groovy. Groovy isn't made to be a replacement, but to be an added improvement and I like that. I already know Java pretty well and I always want to know alittle more about it and things to improve it but I don't want to have to learn an almost completly new syntax system and ways it deals with things. Groovy is a dynamic language that can be used as a scripting language aswell, so all you Ruby, Python, Perl people will already be familiar with some of it.
It's dynamicly compiled into Java Bytcode so it works in JVMs and works seemlessly and easily in Java code!
James Strachan (Groovy's creator) says it the idea behind it best in his weblog entry "Groovy - the birth of a new dynamic language for the Java platform":
"Dynamically typed languages like Ruby and Python are getting quite popular it seems. I'm still not convinced we should all move to dynamically typed languages any time soon - however I see no reason why we can't use both dynamically and statically typed languages and choose the best tool for the job.
I've wanted to use a cool dynamically typed scripting language specifically for the Java platform for a little while. There's plenty to choose from but none of them quite feel right - especially from the perspective of a die hard Java programmer. Python and Ruby are both pretty cool - though they are platforms in their own right. I'd rather a dynamic language that builds right on top of all the groovy Java code out there & the JVM.
Jython, beanshell and Rhino are quite close - but none of them quite feel right for my needs. (JRuby looks dead, Jython's quite behind Python though it is the closest to what I want right now). Apart from beanshell, most of them are languages designed with other use cases or criteria in mind and the bridge to the JVM was an afterthought and so don't quite sit nicely in a Java (platform & language) developers toolkit - even if thats just some minor syntax things (like __init__ and self in Jython).
So I've been musing a little while if its time the Java platform had its own dynamic language designed from the ground up to work real nice with existing code; creating/extending objects normal Java can use and vice versa. Python/Jython's a pretty good base - add the nice stuff from Ruby and maybe sprinkle on some AOP features and we could have a really Groovy new language for scripting Java objects, writing test cases and who knows, even doing real development in it.
I'm finding that most of the time spent in a TDD style development model is actually coding the unit tests. There's typically lots of unit test code for little application code. Also there does seem to be some baggage when writing unit tests in java. This seems a great opportunity for using a concise & powerful dynamically typed language. So the initial idea was to make a little dynamic language which compiles directly to Java classes and provides all the nice (alleged) productivity benefits of python / ruby but allows you to reuse, extend, implement and test your existing Java code - and use that to write your unit tests. Add a little groovy maven plugin and hey presto, we've boosted the TDD development cycle and created a nice dynamically-typed alternative to Java along the way. "
Groovy substantionally reduces the code needed like this example from Wikipedia, it puts three strings into a string array and then shows each through a loop:
Java:
Groovy:
That's amazing, 9 lines to 1 line and that's just the tip of the iceberg! I bought a book just after Christmas called "Groovy Recipes: Greasing the Wheels of Java" and I've learned quite alot from it about Groovy, it's syntax and its integration with Java. Groovy has some nice features like multiline strings, reference things from within "" (<-those) with ${name of whatever}, optional semicolons, optional parenthesis ( e.g println("Hello World") works just as well as println "Hello World"), optional return statements and optional case handeling, witch is incredably handy and when it's compiled, it compiles as if it was added (because it was in the Groovy compiler!).
I'd recommend that every Java developer looks into Groovy because of the time, effiecency it saves and the fact that it can just as easily be used as a scripting language.
Thanks for reading,
Paul Kenny
Links:
Groovy Homepage: http://groovy.codehaus.org/
Java bytecode info: http://en.wikipedia....i/Java_bytecode
Groovy - the birth of a new dynamic language for the Java platform blog entry: http://radio.weblogs...2003/08/29.html
It's dynamicly compiled into Java Bytcode so it works in JVMs and works seemlessly and easily in Java code!
James Strachan (Groovy's creator) says it the idea behind it best in his weblog entry "Groovy - the birth of a new dynamic language for the Java platform":
"Dynamically typed languages like Ruby and Python are getting quite popular it seems. I'm still not convinced we should all move to dynamically typed languages any time soon - however I see no reason why we can't use both dynamically and statically typed languages and choose the best tool for the job.
I've wanted to use a cool dynamically typed scripting language specifically for the Java platform for a little while. There's plenty to choose from but none of them quite feel right - especially from the perspective of a die hard Java programmer. Python and Ruby are both pretty cool - though they are platforms in their own right. I'd rather a dynamic language that builds right on top of all the groovy Java code out there & the JVM.
Jython, beanshell and Rhino are quite close - but none of them quite feel right for my needs. (JRuby looks dead, Jython's quite behind Python though it is the closest to what I want right now). Apart from beanshell, most of them are languages designed with other use cases or criteria in mind and the bridge to the JVM was an afterthought and so don't quite sit nicely in a Java (platform & language) developers toolkit - even if thats just some minor syntax things (like __init__ and self in Jython).
So I've been musing a little while if its time the Java platform had its own dynamic language designed from the ground up to work real nice with existing code; creating/extending objects normal Java can use and vice versa. Python/Jython's a pretty good base - add the nice stuff from Ruby and maybe sprinkle on some AOP features and we could have a really Groovy new language for scripting Java objects, writing test cases and who knows, even doing real development in it.
I'm finding that most of the time spent in a TDD style development model is actually coding the unit tests. There's typically lots of unit test code for little application code. Also there does seem to be some baggage when writing unit tests in java. This seems a great opportunity for using a concise & powerful dynamically typed language. So the initial idea was to make a little dynamic language which compiles directly to Java classes and provides all the nice (alleged) productivity benefits of python / ruby but allows you to reuse, extend, implement and test your existing Java code - and use that to write your unit tests. Add a little groovy maven plugin and hey presto, we've boosted the TDD development cycle and created a nice dynamically-typed alternative to Java along the way. "
Groovy substantionally reduces the code needed like this example from Wikipedia, it puts three strings into a string array and then shows each through a loop:
Java:
public class StdJava
{
public static void main(String argv[])
{
for (String it : new String [] {"Rod", "Carlos", "Chris"})
if (it.length() <= 4)
System.out.println(it);
}
}
Groovy:
["Rod", "Carlos", "Chris"].findAll{it.size() <= 4}.each{println it}
That's amazing, 9 lines to 1 line and that's just the tip of the iceberg! I bought a book just after Christmas called "Groovy Recipes: Greasing the Wheels of Java" and I've learned quite alot from it about Groovy, it's syntax and its integration with Java. Groovy has some nice features like multiline strings, reference things from within "" (<-those) with ${name of whatever}, optional semicolons, optional parenthesis ( e.g println("Hello World") works just as well as println "Hello World"), optional return statements and optional case handeling, witch is incredably handy and when it's compiled, it compiles as if it was added (because it was in the Groovy compiler!).
I'd recommend that every Java developer looks into Groovy because of the time, effiecency it saves and the fact that it can just as easily be used as a scripting language.
Thanks for reading,
Paul Kenny
Links:
Groovy Homepage: http://groovy.codehaus.org/
Java bytecode info: http://en.wikipedia....i/Java_bytecode
Groovy - the birth of a new dynamic language for the Java platform blog entry: http://radio.weblogs...2003/08/29.html
0 Comments On This Entry
Recent Entries
-
-
Improving the look of your Java appson Jun 27 2009 06:22 AM
-
Learning Your Next Languageon Jun 08 2009 03:42 PM
-
EfficientPCon May 25 2009 10:36 AM
-
The Evolving Applicationon May 17 2009 05:37 AM
My Blog Links
5 user(s) viewing
5 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)



Leave Comment









|