Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

Michael Kimsal

Greenhorn
+ Follow
since Nov 08, 2008
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 Michael Kimsal

Chuck Staples wrote:Many of the questions here seem aimed at those who already have some familiarity with Groovy.
As a new Java programmer, I don't have any context for why Groovy / Grails might be better suited for a web application than plain old Java with Restful web services.

Can you briefly list the advantages ( and disadvantages, if any :P ) of using Groovy / Grails vs Restful services?

=chuck



Groovy (and some other alternative JVM languages) offer one meta-advantage over 'pure' Java - easier to read code. In most (almost all?) cases, a developer can express something in Groovy in fewer lines of code than Java. The fewer lines of code don't necessarily lose much expressiveness, but manage to convey the same concepts as 'pure' Java, just with fewer lines of code. Fewer lines of code *generally* means fewer bugs, because there's fewer LOC where bugs can be introduced.

There are numerous comparisons on the web of 'canonical' Java code vs the same functionality expressed in Groovy, and the Groovy code is (almost?) always shorter, often significantly so.

Writing Groovy is Java minus the boilerplate stuff. For those who say that "my IDE make the boilerplate, so it doesn't matter" I say you're wrong - it does matter. Having to work with code that is 100 lines of Java when 20 lines of Groovy would do is painful, leads to potentially more errors, and usually takes longer to make whatever changes/upgrades/fixes need to be made.

Disadvantages? IDE support isn't as snazzy as it is for 'pure' Java. Groovy is slower than Java. Sometimes it's just a bit slower, sometimes it's significantly so. For those sections of your code you can 'fall back' to writing pure Java - they can be mixed and matched in the same file even, so no big issue there (imo).

I'm somewhat biased, but I suspect most people are one way or another...

Michael Kimsal
http://groovymag.com
10 years ago