Thursday, December 26, 2013

I am looking on a new language to pick up and found out about Groovy. According to the website, the language is 'agile dynamic' language.
  1. How is it Agile?
  2. How shorter are the syntax compared to Java's?
  3. Can I use existing Java libs out there?
  4. Lastly, can anyone share their experience on this lingo? What you love and hate
shareimprove this question
This question would really be better suited to Stack Overflow –  Crippledsmurf Jan 27 '11 at 4:38
My understanding is that Groovy is essentially Java with less template syntax and duck typing (strong typing, but determined at runtime instead of compile time). It's been a looong time since I looked at it, so I don't know if they added any other features. Documentation is where I get hung up. –  Berin Loritsch Jan 27 '11 at 13:48
add comment

migrated from Jan 27 '11 at 6:51

This question came from our site for computer enthusiasts and power users.

4 Answers

  1. I don't know either exactly what makes a language "agile", but Groovy let's you put something together quickly.
  2. Depending on your style, quite a lot. You can leave out a lot of Java's boilerplate code, there are no checked exceptions etc.
  3. Yes, without problems.
  4. Mostly I love it, because I like to get things done quickly; I also like that it feels a lot like JavaScript (e.g. Groovy's closures and Javascript's anonymous functions are relatively similar), which is a good thing in a project that uses both; on the other side, many typos are not found by the IDE or the compiler, but only during runtime. Likewise, Intellisense support in the IDE (Netbeans in my case) is by far not as good as in Java. For that reason, I find myself googling the API more often than I would in Java.
shareimprove this answer
add comment
  1. A language can not be agile anymore than a car can be liberal . . . though certain cars may appeal to liberals . . .
  2. The syntax is shorter and more concise in several ways.
    List<String> myList = new ArrayList<String>();
can be shortened to
    def myList = ["one", "two", "three"]
Another way that you write less code is that you needn't catch or explicitly throw any exceptions. Obviously, it's up to you to make sure that your application recovers gracefully from errors, but this is really nice when you are writing a script that does some file I/O.
One of the most important resources to understand how your code can be shorter is the Groovy JDKwhich lists the methods that Groovy adds to your familiar Java objects.
3.Yes, this is the biggest advantage of Groovy over Python or Ruby.
4.I've enjoyed it a lot, particularly in connection with Grails. But if I find myself working on a Java team, I expect to use Groovy for scripts, and for test code, when possible. The biggest disadvantage is the tool support, Eclipse and NetBeans are not ready for prime-time with Groovy. IntelliJ makes it tolerable. Ultimately, Groovy successfully removed most of the boring and awkward parts of Java.
Some good resources: Groovy Goodness Practically Groovy
shareimprove this answer
Your List example is not fair to Java, since List myList = new ArrayList(); works just as well, and is closer to its Groovy counterpart. –  user281377 Jan 27 '11 at 12:24
Hoping my edit makes the advantage clearer. –  Eric Wilson Jan 27 '11 at 13:41
So is List myList = new ArrayList(new String[] {"one", "two", "three"}); But yes, there is a bit less template code. Oh, and regarding point 3, you can use Java libs when you are working with JRuby. The code won't be portable to C based ruby install, though. Same with IronRuby and .NET code. I don't know if there is a JRuby equivalent for Python, but for .NET there is IronPython as well. –  Berin Loritsch Jan 27 '11 at 13:46 
Maybe I should have gone with def map = [one:1, two:2, three:3]? –  Eric Wilson Jan 27 '11 at 13:49
There is no equivalent for that in one line in Java for sure. But the practical differences really aren't so dramatic.–  Berin Loritsch Jan 27 '11 at 13:52
show 2 more comments


oakleyses said...

louis vuitton handbags, oakley sunglasses, louboutin, longchamp outlet, nike shoes, louis vuitton outlet stores, chanel handbags, burberry outlet, prada outlet, jordan shoes, tiffany and co, michael kors outlet, tory burch outlet, louis vuitton outlet, longchamp handbags, nike free, true religion jeans, michael kors outlet, kate spade outlet, polo ralph lauren outlet, tiffany and co, prada handbags, polo ralph lauren outlet, michael kors outlet, michael kors outlet, longchamp handbags, oakley sunglasses, ray ban sunglasses, kate spade handbags, burberry outlet, louis vuitton outlet, louboutin outlet, louboutin, coach factory outlet, air max, air max, coach outlet, gucci outlet, christian louboutin shoes, michael kors outlet, coach purses, ray ban sunglasses, michael kors outlet, louis vuitton, coach outlet store online, true religion jeans, oakley sunglasses cheap

oakleyses said...

ralph lauren, lululemon, air max, hollister, north face, nike air max, polo lacoste, vanessa bruno, timberland, vans pas cher, louboutin, louis vuitton, oakley pas cher, air max pas cher, nike roshe run, air max, true religion outlet, barbour, sac longchamp, air force, hollister, sac louis vuitton, nike free, polo ralph lauren, nike trainers, louis vuitton uk, nike roshe, sac hermes, longchamp, michael kors, sac burberry, sac guess, mulberry, new balance pas cher, converse pas cher, sac louis vuitton, hogan outlet, nike tn, north face, true religion outlet, ray ban pas cher, michael kors, air jordan, nike blazer, nike free pas cher, michael kors pas cher, abercrombie and fitch, ray ban sunglasses

oakleyses said...

mac cosmetics, mont blanc, marc jacobs, canada goose outlet, nike huarache, vans shoes, soccer jerseys, hollister, giuseppe zanotti, beats by dre, abercrombie and fitch, longchamp, insanity workout, celine handbags, bottega veneta, ghd, nfl jerseys, north face outlet, chi flat iron, ugg boots, birkin bag, ugg australia, canada goose, herve leger, ugg pas cher, rolex watches, valentino shoes, canada goose uk, canada goose, ferragamo shoes, canada goose, ugg boots, uggs outlet, north face jackets, soccer shoes, asics running shoes, new balance shoes, p90x, lululemon outlet, canada goose jackets, mcm handbags, instyler, babyliss pro, ugg, wedding dresses, jimmy choo outlet, reebok outlet, nike roshe run

oakleyses said...

parajumpers, karen millen, air max, converse, pandora charms, moncler, louboutin, moncler, links of london, lancel, juicy couture outlet, oakley, hollister, pandora charms, supra shoes, thomas sabo, canada goose, gucci, wedding dresses, timberland boots, swarovski crystal, air max, coach outlet store online, moncler, ray ban, canada goose, moncler, ugg, louis vuitton, swarovski, hollister, montre homme, moncler, hollister clothing store, ralph lauren, rolex watches, moncler outlet, moncler, iphone 6 cases, baseball bats, juicy couture outlet, toms shoes, vans, pandora jewelry, ugg, converse shoes