Linked by Thom Holwerda on Wed 3rd Jan 2007 22:15 UTC, submitted by Tom Nichols
Java Groovy 1.0 has been released and is available for download from the project homepage. "Groovy is a dynamic language for the JVM that integrates seamlessly with the Java platform. It offers a Java-like syntax, with language features inspired by Smalltalk, Python or Ruby, and lets your reuse all your Java libraries and protect the investment you made in Java skills, tools or application servers. Groovy can be used for various purposes, from ad-hoc shell scripting leveraging Java APIs, to full-blown web applications built on Spring and Hibernate through the Grails web framework. It can also be integrated very easily in your applications to externalize business logic, create Domain-Specific Languages, or to provide templating capabilities, and much more."
Order by: Score:
definitely check out groovy
by gregorlowski on Wed 3rd Jan 2007 23:32 UTC
gregorlowski
Member since:
2006-03-20

Groovy is awesome. I used it when I developed a CLI tool in java last week (had to be java because it had to hook into some existing .jar libs). My tool had to include lots of multiline strings with variable substitution in them. Try doing this in pure java -- it's hell.

I usually do stuff like this in ruby, perl, or python where I can use a here-document, $qq{} or triplequotes. In all 3 there are features to substitute a string from a variable into your big string template. There is nothing useful like this in java 1.4, and so you have to put together line after line of "line1 " + var1 + "n" + ... horrible to code and maintain. Sure, there are specialized templating libraries for java, but I needed something general purpose for quick string templating.

So I used groovy for all the stuff that required the string templates, where I could use python-style triple quotes and "${varSubstitution}" in between. You can compile .groovy to java .class files and call them like any other java class as long as you include the groovy core jar in your classpath.

I think groovy would also be awesome for testing and code prototyping, although I haven't used it in those areas yet. I'm still a groovy noob, but I strongly recommend it.

BTW, I know python and ruby, and I experimented with jython and jruby for this but groovy was actually the quickest for me to figure out even though I did not know the language (and I know those others). It was the easiest for me to integrate into my existing java code.

... one more thing, I used groovy with GNU classpath+gij on linux + eclipse 3.2 (java bytecode non-native) on Debian unstable during development. I built my jar (including compiling the groovy classes) under ant. All the features that I needed worked great on this 100% free java stack. I've been using my tool at work this week on Windows+Sun java 1.4.2, and my free-java-stack-compiled version works fine.

Reply Score: 5

RE: definitely check out groovy
by abraxas on Thu 4th Jan 2007 04:49 UTC in reply to "definitely check out groovy"
abraxas Member since:
2005-07-07

BTW, I know python and ruby, and I experimented with jython and jruby for this but groovy was actually the quickest for me to figure out even though I did not know the language (and I know those others). It was the easiest for me to integrate into my existing java code.

How does groovy compares to jython? What makes groovy easier to use and integrate into existing java code? I'm wondering if it is worth taking some time to learn groovy or just stick with what I know (python).

Reply Score: 1

RE[2]: definitely check out groovy
by barspi on Thu 4th Jan 2007 07:58 UTC in reply to "RE: definitely check out groovy"
barspi Member since:
2007-01-04

If you already know Java, Groovy is the most natural language to add scripting or dynamic features to your projects. The syntax is 95% Java + added features like dynamic/duck typing, closures, lots of syntatic sugar for handling lists, maps, loops, and all those features that Ruby and Python fans love.... except that's it's written in a Java syntax, using Java objects transparently, you have access to the full Java API and tons of third party Java libraries... it's all there for you to use.

Even if you hate Java, you should give Groovy a try, at least go to the web site and read the examples and see how comfortable it is to use.

In sum, Java lovers won't need to learn a whole new language to have "agile" features. Java haters, who hate Java's verbosity and pickyness, and the lots of boilerplate code (*) will love a Java-like language where all of that is taken away.


(*) because they never understood why all that is needed in real-life big projects with lots of programmers and strict requirements

Reply Score: 4

JSR ?
by trenchsol on Thu 4th Jan 2007 03:43 UTC
trenchsol
Member since:
2006-12-07

No word on JSR progress.....

DG

Reply Score: 1

Cross-platform
by Lousewort on Thu 4th Jan 2007 10:43 UTC
Lousewort
Member since:
2006-09-12

The best part of this concept is that, as it is based on the JRE, you automatically have the language supporting all the platforms/devices supported by the JRE.

Interpretive native scripting for the JRE

Awesome!

Reply Score: 1

About Grails and Groovy
by sigzero on Thu 4th Jan 2007 15:03 UTC
sigzero
Member since:
2006-01-03

I tried (on XP) but the release and development version and walking through the quick tutorial quickly caused it to bomb. Needs work, though I will use it when it becomes more stable.

While I hate the name "Groovy", I think this is one of the best languages for the JVM to date. I am not a Ruby fan so JRuby is out. I am a Python fan but Jython is so far behind regular CPython why bother.

There are other "native" JVM languages as well. Beanshell is one and Pnuts is another. Pnuts really should get more headline coverage but Groovy gets that.

Reply Score: 2

Grails versus Rails
by g2devi on Thu 4th Jan 2007 17:31 UTC in reply to "About Grails and Groovy"
g2devi Member since:
2005-07-09

From reading the docs, one thing that Grails has that Rails doesn't (from what I've read, due to philosophical reasons) is the ability to switch to Hibernate or other Database Object mappers. In my book, this is an important feature since it allows you to evolve your design without having to do a large rewrite.

Here's a question for the Grails experts. From what I've read (6 months ago), the Rails group absolutely refuses to support compound primary keys (they believe that any database design that uses them should be rewritten). Does Grails support (or have plans to support) compound primary keys (without using Hibernate)?

Reply Score: 3

F3
by Gadrel on Thu 4th Jan 2007 19:48 UTC
Gadrel
Member since:
2005-07-06

I tried Groovy a few months ago, and it was nice. For some things it may even be great - so I hate to say it but I think F3 will take the wind out Groovy's sails.

http://blogs.sun.com/chrisoliver/entry/f3

From where I'm at, it looks F3 will have the features that I really need in a scripting language for Java.

Regardless, congrads to Groovy, I did like it when I used it and appreciate all the effort it took.

Reply Score: 2

RE: F3
by miketech on Thu 4th Jan 2007 21:12 UTC in reply to "F3"
miketech Member since:
2005-07-21

Hi,

isn't F3 something similar to Microsofts Avalon?

I thought the primary goal of F3 is to create interactive user interfaces. This would be different to the goals of Groovy.

Greetings

Mike

Reply Score: 1

scripting?
by Dekkard on Thu 4th Jan 2007 21:21 UTC
Dekkard
Member since:
2006-01-07

does anyone know how this compares to Sleep:
http://sleep.hick.org/

Reply Score: 1