Groovy Language

See http://groovy.codehaus.org/

Introduction

Groovy

Example

class Foo {

  def doSomething() {
    def data = ["name": "James", "location": "London"]
    data.each { key, value ->
      println("entry $key is ${value.length()} characters long")
    }
  }

def closureExample(collection) { collection.each { println("value $it") } }

static void main(args) { def values = [1, 2, 3, "abc"] def foo = new Foo() foo.closureExample(values) foo.doSomething() }
}


Discussion

What does everyone think of this language, (apart from the name being um. ... an interesting choice ;)

Not to sound cliche but if it's stable and does what it claims while still remaining clean and orthogonal I think it's rather groovy.


Its interesting that Groovy appears to meet all the criteria listed on the ScriptingLanguage page (unlike Java) which I guess is a good thing; having a powerful scripting engine that can be used inside Java is very useful.

Folks can use things like JavaPython, JayRuby, Rhino, BeanShell - though Groovy is designed to be a neat scripting language in the Ruby-ish mold which interacts natively with Java without a syntactic, semantic or implementation mapping layer. i.e. groovy classes are just java classes, groovy classes often derive from java.lang.Object, you can create classes in groovy that can be called by Java and vice versa; you can overload methods using Java method overloading rules (i.e. method name and parameter types) and implement Java interfaces etc.


I'm watching this language, since it seems to have some of the core features of Ruby without the annoying perlisms ($-variables, statement modifiers), plus some cool features. The documentation for Groovy hasn't really arrived yet, so for me, the jury is still out. I still don't understand how precisely the two languages are similar and different; e.g. I get the vague impression that Groovy is not as dynamic as Ruby is.

Groovy has access to the mass of Java libraries, however, Groovy dynamically extends Java's built-in collections, arrays, and Strings with closure-friendly features. So it essentially makes the JDK a lot more scripting-friendly. See http://groovy.codehaus.org/quickStart.html for examples.


CategoryProgrammingLanguage


EditText of this page (last edited October 1, 2014) or FindPage with title or text search