en · de

JAX 08: Groovy, a successful dynamic language for the JVM

by Thomas,
assono GmbH, Standort Kiel,


A picture named M2

The Dynamic Languages Day, which is part of the JAX 08, starts with a session about Groovy:

Guillaume Laforge:
Groovy, a successful dynamic language for the JVM


Groovy is Java-like and intregrates seamless with Java; you can mix both, same strings, regex, APIs, OO, threads, security etc.

It's fully oo, Closures, Properties, Operator overloading, Multimethods, GPath, BigDecimal, etc. Lots of interesting language features missing in Java. Ideal for DSLs

Already integrated in a lot of projects, LOTS of projects, like Grails, JBoss Seam, ServiceMix, SoapUI, Turbine, Oracle, Mule, Spring, IntelliJ IDEA, Ant, Maven, ...

Used in mission-critical apps:
e. g. Mutual of Omaha, Fortune 500 US insurance company,
45,000 lines of Groovy (half business code, half test code), risk calculation engine, ideal for business rules expression
Reasons for Groovy: exact arithmetic support, perfect Java integration, closures


Groovy Syntax
Groovy is a Java superset
Valid Java code is also valid Groovy code, but using Groovy's language constructs, you get shorter, "groovier" programs

Literals for lists, maps, ranges, regexes,
strings

Multiline strings: """
first line of string

last line of string """

Gstrings: println "My name is $(name)"


Closures

especially useful with each, eachLine,
findAll iterators; "it" means current value



Groovy APIs

Simplified APIs for common tasks, like

Swing Builder

easy, concise way to generate UI, e.
g. frame with panel with labels, text fields and buttons, even with listeners

using closures the code is really short


Automating Office applications

ActiveXProxy is a wrapper for COM objects

because Groovy is a dynamic language
(double dispatch), you can simply call the usual methods on your COM objects
(like in VB)


Domain-Specific Languages

Why create a DSL?

New in Groovy 1.5

Java 5 Features, like Annotations, generics,
...


Groovy switch statement works on a lot
more things, like lists, enums, etc.


ExpandoMetaClass from Grails: expand
existing classes


IDE support

Integrating Groovy in your apps

http://groovy.codehaus.org

Event Technical article JavaScript Other

You have questions about this article? Contact us: blog@assono.de

Sie wollen eine individuelle Beratung oder einen Workshop? Read more

More interesting entries

Any questions? Contact us.

If you want to know more about our offers, you can contact us at any time. There are several ways to contact us for a non-binding first consultation.

assono GmbH

Location Kiel (headquarters)
assono GmbH
Lise-Meitner-Straße 1–7
24223 Schwentinental

Location Hamburg
assono GmbH
Bornkampsweg 58
22761 Hamburg

Phone numbers:
Human resources department: +49 4307 900 407
Marketing department: +49 4307 900 411

E-Mail adresses:
contact@assono.de
bewerbung@assono.de