Josh Brown

Ranch Hand
+ Follow
since Oct 09, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Josh Brown

I found this post on Actors in Groovy and thought it was interesting:

Actors in Groovy

Enjoy!
11 years ago
Back to the original question - another reason that Groovy won't ever replace Java is that it's different. Java has static typing, and even though Groovy has (optional) static typing, it doesn't really work the same as Java. For example (try running this in the groovyConsole):


Java wouldn't allow you to assign the String literal "1" to x, since x is declared as an int. It would break at compile time. Groovy allows it - it just converts the String to its ASCII value.

I'm guessing there are lots of people out there who are firm believers in static typing and therefore would never use Groovy.
[ December 07, 2008: Message edited by: Josh Brown ]
11 years ago
It seems like others have had the same question here. To sum up their answers, Groovy can:
(1) increase productivity
(2) give you dynamic capabilities where Java can't
(3) allow you to write less code (which may be the same as increased productivity)

https://coderanch.com/t/47/Groovy/Why-Groovy-baby

https://coderanch.com/t/38/Groovy/do-do-Groovy-Java
11 years ago
I agree with the others who have said that IntelliJ IDEA has the best Groovy support. I've tried Eclipse and Netbeans, and they're just nowhere close to IDEA.
11 years ago
With Groovy, you can use all of the same Java libraries you'd use to build GUI apps. Groovy also provides builders that make writing Swing apps so much easier than in Java. Check out the example of the SwingBuilder. It's simple and intuitive. You may also want to have a look at the SwingXBuilder.
11 years ago
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 ]
11 years ago
Does the Eclipse plugin work well? I've used some Eclipse plugins that are severely lacking, so I'm a bit wary. What about the plugin for IntelliJ? Have you worked with it at all? How does it compare to Eclipse?
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 ]
11 years ago
Thanks for all your time and answers!
11 years ago
From what I know, the advantage to using Groovy over Java or Grails over JEE is that Groovy/Grails are just simpler. Less code, less development time, less deployment time, etc. I know that Grails uses Spring & Hibernate underneath, so those are two less frameworks your developers would have to learn.

I'd recommend showing some examples of how Groovy is simpler than Java. Groovy Beans are one way, along with Collections and Processing XML. There are lots of others, but that'll give you a good start. Get familiar with the language, play around with it, learn it really well, and when you're convinced that it would be a great language to use on a project, you'll be able to convince the architecture group.
11 years ago
From the link above:

"Closures may be 'bound' to variables within the scope where they are defined"

In addition to that, you can pass a closure as an argument to a method. Then that method can call your closure. This means you can give a method some block of code, and the method can execute that block of code.

I'd recommend reading the Formal Definition on the Groovy site.
[ April 10, 2008: Message edited by: Josh Brown ]
11 years ago

Originally posted by Chris Patti:


In a relatively recent episode of the Java Posse podcast, Tor Norby, one of the Netbeans team's heavy hitters, mentioned that Sun had not been focusing resources on Groovy support because other IDEs have already 'cornered that market' (I'm paraphrasing, perhaps even poorly, but that's the idea).

To be fair though, I don't think this means that Sun doesn't support Groovy. Rather, IMO it means that Sun simply doesn't feel it's profitable or smart to devote developer resources to enhancing Netbeans groovy support when IntelliJ and others are already doing a lot in that area elsewhere.



I'm not going to debate whether Tor Norby said that, but I don't think he's right. I don't think other IDEs have cornered the market, because IntelliJ has the only good Groovy plugin that I've seen. But you have to pay for IntelliJ, and I think there are still a lot of developers out there who want a free IDE. I've worked with the Eclipse plugin, and it's not good. The plugin for NetBeans isn't good either, but they're not that far behind. It's not too late for them to catch up by improving on their plugin.
11 years ago
If NetBeans is any indication, I'd say Sun isn't investing very heavily in Groovy. The Groovy plugin for NetBeans is nowhere near as good as the Groovy plugin for Eclipse. To me, this would indicate that Sun isn't pushing Groovy very hard, as IDE support is a huge contributor to a language's success these days.
[ April 09, 2008: Message edited by: Josh Brown ]
11 years ago
Here's another:

Using MarkupBuilder

And perhaps the Processing XML page on Groovy's website will also help to answer your question.
11 years ago
Good point. I didn't realize that in my Groovy test, I was reassigning myList. Here's what I was doing in Groovy:



This, as you pointed out, is not the same as the Java code I posted, since myList is reassigned. Groovy does in fact throw a ConcurrentModificationException if you try to remove an element from a collection over which you're iterating.

I'm not aware of a Groovy equivalent to your Ruby example, unfortunately.
11 years ago