This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
1) A number of seasoned Java programmers are seriously looking at a place in their toolbox for scripting languages running on the JVM and specifically scripting languages in the context of web frameworks. Could you explain what the advantages of Groovy and specifically Groovy on Grails are as compared with Ruby/JRuby on Rails?
2) I've heard good rumors about Ruby/JRuby support coming to NetBeans. Is there equivalent support for Groovy in NetBeans or Eclipse and/or what environment do you recommend for Groovy development?
I'm sure a Grails person will be along soon to give you an authoritative answer to that part of your question.
If you are looking for a dynamic language optimised for the JVM than I think Groovy has the edge over the alternatives. The integration with Java is seamless. There are no special libraries to import to work with Java classes. Java code can work with Groovy classes without knowing or caring that they are written in Groovy. Java classes can subclass Groovy classes and Groovy classes cab subclass Java classes. There are some really subtle issues in selecting methods which can only really be solved if, like Groovy, you allow values to be optionally typed or to be cast to a type.
Groovy, unlike Ruby supports Unicode without the need for converters and helper packages. This makes things like XML manipulation really very simple.
I understand that the Netbeans people want to improve their support for all dynamic languages and that a very welcome attitude. There is an existing Netbeans project called Coyote which aims to do this but it's not very visible at the moment. We gave IDEA and Eclipse plug-ins for Groovy. The Eclipse plug-in in particular is very popular and is being energetically developed at the moment.
One of the Groovy books being published in the next month or so (http://www.amazon.com/o/ASIN/0123725070/) will come with a custom IDE which has been developed to support ther use of Groovy as a teaching tool - I'm looking forward to playing with that tool.
Joined: Aug 22, 2005
Regarding number 1, could you give some examples or maybe a comparison between how you would do something in Ruby/JRuby vs. the way you would do it in Groovy and why the Groovy way is better?
I'm no authority but I feel inclined to shoot my mouth off on this topic. Basically Dierk and John are referring to Java integration. Ruby is an entirely different language with an entirely unique API whereas Groovy is more of an extension or enhancement to the Java language. Here's a perfect example of code you can write in Groovy:
The idea here is that the barrier to entry or learning curve is much more shallow for beginners. Not being a Ruby expert I'm only guessing the Ruby equivalent would be something like:
While that looka like a counter example of Groovy's advantages consider the following Groovy equivalent:
Groovy takes the appraoch of bringing all of the things programmers want into the Java language while Ruby is a whole new language and platform created from the ground up. There is the JRuby project that allows you to run Ruby scripts on a JVM but again the API is recreated. From what I've seen so far Groovy can do just about everything Ruby can do but with tighter Java integration. That's not to say that Groovy is better than Ruby but that it may be easier to adopt for the typical Java programmer. I provide a more in depth explanation of the above rambling here on my site.
Holla at me...<br /><a href="http://codeforfun.wordpress.com" target="_blank" rel="nofollow">http://codeforfun.wordpress.com</a>
Joined: Aug 22, 2005
Thanks for the examples. That's exactly the kind of information that I was looking for.