Feeling Groovy at Last



Email    print   
February 1, 2007 —  (Page 1 of 2)
After many delays, the Java scripting language Groovy is finally shipping. The 1.0 release became official the first working day of this year, and it promises to bring lots of good things to many a Java developer.

Groovy is a dynamic scripting language that was purpose-built for the Java platform. By this I mean that it is not the port of another idiom (in the Jython, JRuby mold), but a language that was designed for the JVM and specifically for use by Java developers. The goal—which appears to have been met—was to provide a simplified syntax for much of Java’s notoriously wordy code.

Groovy does away with the tediousness via lots of syntactic sugar that makes Java development really a pleasure. For example, when you define a class, Groovy automatically creates default getters and setters for fields. Lists and maps—Java’s most overused collections—are first-class members of the language. You declare and load them with values in a single concise statement akin to Java’s syntax for arrays.

Groovy also offers closures, which are a technique made famous by Ruby. Closures have many definitions, and a rather dull meme in programming language blogs these days is arguing over what constitutes a closure. Putting aside the academics’ sparring, closures are essentially anonymous blocks of code that are easily attached to a statement or function. They make it simple to specify an action without having to define a class and then a method. Instead, the actual code to be executed is stated inside parentheses and attached to another action. For example, a closure called find, let’s say, can be attached to a collection iterator to look for a specific element. The closure contains only the equality statement to test for the desired element. Another one, called each, can be attached to indicate actions that should occur for every element in the collection. This design makes for concise code that is readily understandable.

Groovy offers lots of other convenience features in areas where Java and other traditional languages tend to be weak, such as duck typing and special syntax to simplify common tasks like XML processing.




Pages 1 2 


Share this link: http://sdt.bz/30044
 
Most Read Latest News Blog Resources

Add comment


Name*
Email*  
Country     


  • Comment
Loading




close
NEXT ARTICLE
Sun extends Groovy, PHP support to NetBeans
Version 6.5 of the IDE will see complete support for those two languages along with complete support for JavaScript and a separate, limited preview of Python support. The company says that it has increased the quality of NetBeans' Java code as well Read More...
 
 
 
 
News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 

Download Current Issue
FEBRUARY 2012 PDF ISSUE

Need Back Issues?
DOWNLOAD HERE

Want to subscribe?


 
blogs tab
Are you at risk for burnout?
Burnout is a severe problem and it can strike at any time. Here's how to tell if you are nearing the edge.
02/09/2012 02:16 PM EST

Agility, mom, and apple pie
If we're to evaluate the state-of-the-art in software development, we should start with the values espoused in the Agile Manifesto.
02/07/2012 11:57 AM EST

RIM woos developers with free tablet
How do you get more apps ported to the BlackBerry PlayBook? By giving every developer a free tablet, of course!
02/04/2012 01:57 PM EST

GitHire: Use Headhunters to Find Your Perfect Programmer
Are you a hiring manager tired of scouring the job boards? Check out this new service that will find 5 people interested in your jobs.
02/03/2012 12:17 PM EST

Facebook claims hacker cred
Facebook's SEC S-1 filing form includes a short essay on the Hacker Way by Mark Zuckerberg himself.
02/02/2012 08:26 AM EST

Ryan Dahl steps down
Ryan Dahl, creator of Node.js, steps back from his position as gatekeeper for the project.
02/01/2012 04:58 PM EST

 
Events calendar tab
2/13/2012 to 2/16/2012
Santa Clara
TechWeb

2/26/2012 to 2/29/2012
San Francisco
BZ Media

2/27/2012 to 3/2/2012
San Francisco
RSA

3/4/2012 to 3/7/2012
Las Vegas
IBM Tivoli

3/5/2012 to 3/9/2012
San Francisco
TechWeb