Dashboard > Groovy > Home
Home Log In | Sign Up   View a printable version of the current page.

Added by Bob 'The Despot' McWhirter , last edited by glaforge on Mar 03, 2008  (view change)
Labels: 
(None)

Groovy...

  • is an agile and dynamic language for the Java Virtual Machine
  • builds upon the strengths of Java but has additional power features inspired by languages like Python, Ruby and Smalltalk
  • makes modern programming features available to Java developers with almost-zero learning curve
  • supports Domain-Specific Languages and other compact syntax so your code becomes easy to read and maintain
  • makes writing shell and build scripts easy with its powerful processing primitives, OO abilities and an Ant DSL
  • increases developer productivity by reducing scaffolding code when developing web, GUI, database or console applications
  • simplifies testing by supporting unit testing and mocking out-of-the-box
  • seamlessly integrates with all existing Java objects and libraries
  • compiles straight to Java bytecode so you can use it anywhere you can use Java

Experience the latest Groovy 1.5

Groovy 1.5, the latest major and stable version of the popular dynamic language for the JVM, has been released. In a nutshell, it brings new features like Java 5 annotations, generics and enums, it provides significant performance gains, new meta-programming capabilities, new and improved tooling support like the new joint Groovy/Java compiler, the new interactive shell, or the Groovy Swing console, and a few other additions in its syntax, like the new Elvis operator or the ability to omit parentheses in methods with named arguments to make DSLs even more readable. InfoQ covers the novelties in this new milestone of the project. With all these improvements and new features, don't waste a single second, go download Groovy 1.5 and give it a try.

Groovy, an award-winning creative and innovative project

 JAX is the most important Java conference in Germany. Every year, the organizers are running a contest to select the most innovative and creative projects. From over 40 proposals, the jury selected only ten nominees. Although great projects were selected, like the Matisse GUI builder in NetBeans, or the Nuxeo Enterprise Content Management solution, Groovy won the first prize! It is a great honor and a huge pleasure for us to receive such a prize, especially knowing the cool projects we were competing with, or the past winners like the Spring framework.
Dierk König, author of the best-selling "Groovy in Action" book, received the prize in the name of the Groovy community, after having presented several sessions on Groovy at this conference. This award proves and reaffirms how innovative, creative and influential the Groovy project is for the Java community.


"Groovy is like a super version of Java. It can leverage Java's enterprise capabilities but also has cool productivity features like closures, builders and dynamic typing. If you are a developer, tester or script guru, you have to love Groovy."






Samples

A simple hello world script:

def name='World'; println "Hello $name!"


A more sophisticated version using Object Orientation:
class Greet {
  def name
  Greet(who) { name = who[0].toUpperCase() +
                      who[1..-1] }
  def salute() { println "Hello $name!" }
}

g = new Greet('world')  // create object
g.salute()              // Output "Hello World!"


Leveraging existing Java libraries:
import static org.apache.commons.lang.WordUtils.*

class Greeter extends Greet {
  Greeter(who) { name = capitalize(who) }
}

new Greeter('world').salute()


On the command line:
groovy -e "println 'Hello ' + args[0]" World


Documentation [more]

Getting Started Guide
How to install and begin using Groovy as well as introductory tutorials.

User Guide
Provides information about using the Groovy language including language facilities, libraries and programming guidelines.

Cookbook Examples
Illustrates larger examples of using Groovy in the Wild with a focus on applications or tasks rather than just showing off the features, APIs or modules.

Developer Guide
Contains information mainly of interest to the developers involved in creating Groovy and its supporting modules and tools.

Testing Guide
Contains information of relevance to those writing developer tests or systems and acceptance tests.

Advanced Usage Guide
Covers topics which you don't need to worry about initially when using Groovy but may want to dive into to as you strive for Guru status.

Modules [more]

The following modules and contributions are currently available:

  • COM Scriptingscript Windows ActiveX and COM components with Groovy
  • Gant
  • GFreeMarkeran integration of the FreeMarker template engine for Groovy
  • GMavenGMaven provides integration of the Groovy language into Maven.
  • Google Data Supportmakes using the Google Data APIs easier from within Groovy
  • Grama simple xdoclet-like tool for processing doclet tags or Java 5 annotations
  • GraphicsBuilderGraphicsBuilder is a Groovy builder for Java 2D
  • Grapplet
  • GriffonDekstop Enhancements for Groovy
  • GrooshProvides a shell-like capability for handling external processes.
  • Groovy Jabber-RPCallows you to make XML-RPC calls using the Jabber protocol
  • Groovy Monkeyis a dynamic scripting tool for the Eclipse Platform
  • Groovy SOAPcreate a SOAP server and make calls to remote SOAP servers using Groovy
  • GroovyLabProvides a domain specific language (DSL) for math engineering (matlab-like syntax).
  • GroovyRestletGroovy DSL for constructing Restlet application
  • GroovySWTa wrapper around SWT, the eclipse Standard Widget Toolkit
  • GroovyWSGroovySOAP replacement that uses CXF and Java5 features
  • GSPmeans GroovyServer Pages, which is similar to JSP (JavaServer Pages)
  • GSQLsupports easier access to databases using Groovy
  • JideBuilderJideBuilder is a Groovy builder for the open source JIDE Common Layer
  • Native Launchera native program for launching groovy scripts
  • Windows NSIS-Installera Windows-specific installer for Groovy
  • Windows Servicesframework for Groovy-based WinNT (Windows) Services
  • WingSBuilderWingsBuilder is a Groovy builder for the wingS Framework
  • XMLRPCallows you to create a local XML-RPC server and/or to make calls on remote XML-RPC servers
  • Grailsa Groovy-based web framework inspired by Ruby on Rails
  • GORMthe Grails Object-Relational Mapping persistence framework
  • GroovyPluginA Groovy plugin for JSPWiki

Enjoy making your code groovier !!!!

Latest news

If you wish to stay up-to-date with our vibrant community, you can learn more about:

And below, you will find the latest announcements:

Last changed May 12, 2008 02:19 by Jason Dillon
Labels: gmaven

This is a minor maintenance release.

For more details on whats included in this release please see the release notes:

Posted at 12 May @ 2:19 AM by Jason Dillon | 0 comments
Last changed May 07, 2008 17:18 by Christian Helmbold

The first german wiki for Groovy and Grails developers was launched: www.groovy-forum.de/wiki/
Join it and share your knowledge with other german speaking developers.

Posted at 08 May @ 12:00 AM by Christian Helmbold | 1 comment




Updated by Paul King
Apr 23, 2008 01:30

Hi,

I am unable to get the example that you have posted on InfoQ for using the tripple dot notation of variable args list. i.e I cut and pasted the following code

int sum(int someInts...) {
    def total = 0
    for (int i = 0; i < someInts.size(); i++)
        total += someInts[i]
    return total
}

assert sum(1)       == 1
assert sum(1, 2)    == 3
assert sum(1, 2, 3) == 6

into groovyconsole and I get the following:

Exception thrown: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script14: 1: unexpected token: ... @ line 1, column 21.
1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script14: 1: unexpected token: ... @ line 1, column 21.
1 error

Am I missing something?

Thanks

Vimal 



Updated by Paul King
Apr 23, 2008 01:33

Vimal,

int sum(int someInts = 5) {
    def total = 0
    for (int i = 0; i < someInts.size(); i++)
        total += someInts[i]
    return total
}
 
assert sum(1) == 1
assert sum(1, 2) == 3
assert sum(1, 2, 3) == 6

I tried it, but now i get another error:

groovy.lang.MissingMethodException: No signature of method: java.lang.Integer.size() is applicable for argument types: () values: {}
	at Script14.sum(Script14:3)
	at Script14.run(Script14:8)

Vimal, try this:

int sum(int... someInts) {
    def total = 0
    for (int i = 0; i < someInts.size(); i++)
        total += someInts[i]
    return total
}

assert sum(1)       == 1
assert sum(1, 2)    == 3
assert sum(1, 2, 3) == 6
Site running on a free Atlassian Confluence Open Source Project License granted to The Codehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.2 Build:#919 Nov 26, 2007) - Bug/feature request - Contact Administrators