my dog learned polymorphism*
The moose likes Groovy and the fly likes What do I can do with Groovy that I can't with Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "What do I can do with Groovy that I can Watch "What do I can do with Groovy that I can New topic
Author

What do I can do with Groovy that I can't with Java?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Hi,

I'd like to know what kind of stuff do I can do with Groovy that I can't with Java.
In other words, which situations would be more vantajous using Groovy than only Java?

Thank you.


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

As far as I know about groovy that it is built on JAVA itself and runs in same JVM. So I dont thnik that there is something that you can do with Groovy but not with Java.


Groovy makes the same task easier to write in that too in very less time as compared to Java.
[ October 21, 2008: Message edited by: Himanshu Gupta ]

My Blog SCJP 5 SCWCD 5
Christophe Deniaud
Greenhorn

Joined: Jan 10, 2008
Posts: 21
Hello,

I�m perhaps wrong but I think that with groovy, you can use scripts which are not directly compiled in code (as with any script language).
This allows you to adapt parts of your program�s feature without needing any development tool.

Chris
Josh Brown
Ranch Hand

Joined: Oct 09, 2007
Posts: 35
Groovy is great for xml parsing. It's so much easier than parsing xml in Java.

http://groovy.codehaus.org/Reading+XML+using+Groovy's+XmlSlurper

http://groovy.codehaus.org/Reading+XML+using+Groovy's+XmlParser
[ October 21, 2008: Message edited by: Josh Brown ]

Josh
Inside the Machine
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Originally posted by Christophe Deniaud:
Hello,

I�m perhaps wrong but I think that with groovy, you can use scripts which are not directly compiled in code (as with any script language).
This allows you to adapt parts of your program�s feature without needing any development tool.

Chris



This is what i got from Groovy website :

compiles straight to Java bytecode so you can use it anywhere you can use Java


So as far as I understand, groovy code is compiled and changed into byecode. That is why it is easy to use in Java just like any other java class.
Jason Mayer
Ranch Hand

Joined: Oct 16, 2007
Posts: 31
Here's something you can do in groovy that you can't do in java. Write a string that doesn't need to escape backslashes.

Seriously though, there's not much you can do in groovy that you can't do in Java. On the flip side, almost anything you can do in Java can be done using less lines of code in groovy.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: What do I can do with Groovy that I can't with Java?