• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Why will I use Groovy?

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...?
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting whether these articles corresponds the real truth?!!
http://en.wikipedia.org/wiki/Groovy_(programming_language)
http://www-128.ibm.com/developerworks/java/library/j-alj08034.html
 
Daniel Jabonete
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Serg for the informative links!

So Groovy is another OOP Language, why will I use it, as a Certified Java Professional point of view. Does it offer other features I cannot do with Java?
 
Author
Posts: 135
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Groovy is lightweight, dynamic, and provides a higher level of abstraction, but at the same time, you can mix it with Java. If you are interested in Aspects, you can do that with Groovy very easily using MOP or MetaObject Protocol. Groovy enhances Java instead of replacing it.
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I hope I may join this discussion because for me it's the same question: "Why Groovy (or other dynamic and scripting languages)?

I've been searching quite long for real advantages of languages like Groovy but I still haven't found them. At least I can't imagine to use such a language for programming serious applications. Don't get me wrong, I would like to see some benefits in using Groovy where appropriate and perhaps better than Java. But a lot of the "features" of dynamic languages appear to me as disadvantages. For example all the useful compile time checks and IDE support (auto completion etc.) are missing or not really good.
But most important for me is the big difference when you have to look at some piece of source code. Code in Groovy (and other similar languages) often may be much shorter or concise than the same code in a language like Java. But if it's not my own code and it's more than just a few lines, it's exactly this advantage which becomes a big disadvantage in my opinion. You can't figure out what types some variables might have, a lot of this useful "magic" going on isn't really easy to understand and so on...

So I see Groovy's place where you have to script a fast and small solution to a specific problem. Or if someone is new to programming and quickly wants to see results it could be nice. And it may come in handy when you don't have a powerful IDE to work with. Of course this is only my personal opinion. Perhaps someone finally can convince me when and why I should give Groovy a try. Or can "Programming Groovy" perhaps show me what advantages of Groovy I'm missing as a "normal" Java programmer?

I'd be glad to hear your opinions to that!

Marco
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to agreed with Marco. I started to learn this new language Last month and am still have wandering about the "if and when I can use it in my development"

It would be nice if some one can share some good experience about using this in decent size of development project.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But a lot of the "features" of dynamic languages appear to me as disadvantages. For example all the useful compile time checks and IDE support (auto completion etc.) are missing or not really good.


They're getting better, especially compiler checks. IntelliJ IDEA has done a terrific job leading the way. Autocomplete is fairly decent. As you learn to program more Groovily, though, you'll discover that you don't need to use autocomplete nearly as much simply because you write less code.

But most important for me is the big difference when you have to look at some piece of source code. Code in Groovy (and other similar languages) often may be much shorter or concise than the same code in a language like Java. But if it's not my own code and it's more than just a few lines, it's exactly this advantage which becomes a big disadvantage in my opinion. You can't figure out what types some variables might have, a lot of this useful "magic" going on isn't really easy to understand and so on...


Java is a butter knife. Groovy is a chef's blade. If you let a fresher in the kitchen, yes it's more dangerous to give him/her a sharper tool. From my perspective, the only advantage Java has here is when you're dealing with an inexperienced programmer because then the programmer will simply make less of a hack-job.

In some places our "chef" might realize that a portion of code is cleaner if static typing is used. You're allowed to do that in Groovy. You can go to normal Java ways when you need to.

I believe that people who write horrible Groovy code will also write horrible Java code. If some goofball starts passing around an indecriptive variable called flag (or worse, f), in Java I'm guaranteed that I'll know its type is boolean. This gives me a lowest common denominator for bad code in Java, somewhat like a safety net.

Follow a few simple principles like keeping methods succinct, and code will be easier to read.

Perhaps someone finally can convince me when and why I should give Groovy a try. Or can "Programming Groovy" perhaps show me what advantages of Groovy I'm missing as a "normal" Java programmer?


Why do you feel someone needs to convince you? If you're happy with Java as it is, then stick to it. But if you're hungry for a more powerful tool, Groovy's one of the best and most fun to explore.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by john Lin:
It would be nice if some one can share some good experience about using this in decent size of development project.


I'm currently using it in an SOA architecture that has an MQ backbone.

Groovy has made it tremendously easier to deal with XML messages in our services by using cool things like XmlSlurper and MarkupBuilder.
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How good is unit testing with our old JUnit for .groovy classes?
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your detailed answer, Marc!

Java is a butter knife. Groovy is a chef's blade. If you let a fresher in the kitchen, yes it's more dangerous to give him/her a sharper tool. From my perspective, the only advantage Java has here is when you're dealing with an inexperienced programmer because then the programmer will simply make less of a hack-job.



What a cool metaphor But that was indeed another problem I suspected to have when you use Groovy for bigger projects. On the other hand you're of course right. With most programming language it's possible for good programmers to produce good code and on the other hand for bad programmers to produce bad code. Perhaps I'll have to gain some experiences in practical use of Groovy. At the moment I'm still not convinced if it's better to leave it to programmers to produce better or cleaner code (or bad code as well).

Why do you feel someone needs to convince you? If you're happy with Java as it is, then stick to it. But if you're hungry for a more powerful tool, Groovy's one of the best and most fun to explore.



That's mostly because I don't belong to that kind of people who only like what they already know and don't even try to learn something new. And of course it's alway interesting to learn new technologies in particular if they could make daily work easier.

So you have convinced me in some points already. And I guess there's a lot of learning by doing like in many other areas of computer science. Which way would you recommend to get started with Groovy? Using it for daily scripting? Trying to integrate it in some parts of real application programming?

Thanks in advance for all the tips!

Marco
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sreerupa basu:
How good is unit testing with our old JUnit for .groovy classes?



Very good. I'm just a build monkey (release engineer) but we have a very large application here at The Broad Institute, and more and more developers are utilizing Groovy for their unit tests. Less boiler plate code and more abstraction means two things: It's much easier to construct meaningful, correct tests, which makes developers more likely to write said tests, and everyone's quality of life improves.

One test in particular went from hundreds of lines to less than 10, and readability actually improved! Groovy for testing is a win, pretty much hands down.
 
Daniel Jabonete
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believed most of us here are in search (or hungry) of much powerful and at the same time fun to explore tools. But before integrating or introducing these tools in particular projects some justifications are needed, especially with the management. Some organization preferred or implemented a certain standard approaches. If it is just an enhancement it can be maybe consider later, if it is �mix� then that seems a red light.

But ofcourse for our own personal time, we can try anything we want.




x----------x

In the Art of War:

�Divide and Conquer�
[ April 08, 2008: Message edited by: Daniel Jabonete ]
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have also found this interesting article on the advantages of using Groovy for JUnits -

http://www.javalobby.org/java/forums/t94245.html
 
Marko Kencheto
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting: ability to learn new technologies is allways very important, but what do you do in case, if the head allready look like filled tee cup till edges??? Is everything limited or not?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, most of us just go on and learn new stuff and gradually forget the old stuff we haven't used in a while. This generally happens naturally. Does your memory throw an InsufficientMemoryError instead?
[ April 11, 2008: Message edited by: Jim Yingst ]
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to get started?
Fool around using the Groovy Console. This tool makes it pretty easy to quickly try new concepts in Groovy without an IDE. I had a lot of fun finding SwingBuilder examples online and dropping them into the Groovy Console. Voila! Instant Swing app!

How to introduce Groovy in a project?
In some companies this may be an uphill battle. One of the easiest ways to start using Groovy is if you work on a project that's not doing as much unit testing as you'd prefer. You can easily set up Groovy unit tests and even choose not to commit your Groovy code to the repository if you think management would throw a fit. You find more errors in the code base and you get experience with Groovy - sounds like a win-win to me.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marc makes a great point - unit testing is an easy way to sneak some Groovy into your project.

I've been really interested in Groovy and am currently on a project that doesn't use it. I'm maintaining an older application, and the app didn't have any unit tests at all when I started. I decided to write some units test using Groovy, and it's great! Groovy just looks so much nicer than Java, and it provides a lot of nice features that are great for unit tests.
[ April 11, 2008: Message edited by: Josh Brown ]
 
Marko Kencheto
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jim,

thanks, i'm not "Terminator", but sometimes mark, that happy peoples are that one, that find "middle" beetween experience (application of learned stuff in reality) and lerning proccess... my oppinion -it can be wrong!
 
It's exactly the same and completely different as this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic