Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rogerio Kioshi
Ranch Hand
Posts: 690
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Christophe Deniaud
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic