Facilitating the spread of knowledge and innovation in professional software development

Contribute

### Topics

InfoQ Homepage Articles What's New in Groovy 1.5

# What's New in Groovy 1.5

This item in japanese

Groovy, the Java-like dynamic language for the JVM, matures over time like good wines. After the successful release of Groovy 1.0 in January 2007, the next major milestone with the 1.5 label already hits the shelves. With it, come several interesting novelties that we will examine in this article. The major addition to the language is the support of Java 5 features with annotations, generics and enums, making Groovy the sole alternative dynamic language for the JVM fully supporting frameworks like Spring, Hibernate, JPA, Google Guice, or TestNG. Apart from the new Java 5 features, a few syntax enhancements find their way in the language, as well as a more powerful dynamic behavior customization, a Swing UI builder on steroids, and improved tooling support.

## A groovier Groovy and why it matters

Groovy's key selling point has always been its seamless integration with Java. You can mix and match Groovy and Java classes together in very easy ways: You may have a Groovy class extending a Java class implementing a Groovy interface, and vice versa. Most of the other alternative JVM languages unfortunately won't let you seamlessly interchange classes of two different languages. So if you want to use the best language for the job without compromising your nice class hierarchy, you won't have many options to choose from, and Groovy gives you all the freedom for integrating both languages in the most transparent way.

Groovy shares the same libraries, the same object model, the same threading model, and the same security model as Java. In a way, you can consider Groovy as an implementation detail of your Java project, without having to bear problematic impedance mismatch issues.

Groovy is Java, and Groovy makes Java groovier. Compared with other languages, Groovy is certainly the language that provides the flattest learning curve to Java developers, thanks to a very similar syntax.

This is even more important to keep in mind that Groovy generates normal Java bytecode and uses the usual JDK libraries, so you won't need to learn whole new APIs or have complex integration mechanisms: out of the box, Groovy and Java are interchangeable. The added benefit is that you can protect the investment you made in Java skills for your developers, or in costly application servers, or third party or home-grown libraries, as you can reuse all of them without a problem from Groovy.

Speaking of calling into JDK, third party, or in-house libraries, alternative languages which don't support strong typing, can't always call all Java methods because of the fact they can't choose a certain polymorphic variation of the same method. When choosing an alternative language to improve your productivity or make your code more readable, if you need to call other Java classes, you will have to be very careful to the choice of language you will make, as you may encounter some road blocks along the way.

These days, all major Enterprise frameworks require the use of features like annotations, enums or generics, to be leveraged at their fullest extent. Fortunately, with Groovy 1.5, developers can benefit from the support of all these Java 5 features in their projects. Let's see how annotations, enums and generics can be used from Groovy.

The Groovy compiler always generates Java bytecode which is compatible with older Java VMs, but relies on JDK 1.4 for the core libraries it is using. However, for certain of these Java 5 additions, using Java 5 bytecode was required, so that, for example, the generated classes may contain the bytecode information representing annotations with runtime retention policy. So although Groovy 1.5 can run on JDK 1.4, certain of these features will only be usable on JDK 5 - when this is the case, it will be mentioned in this article.

### Variable arguments

In Java 5, the ellipsis notation was created to denote methods with variable length arguments. With those little triple dots, Java lets users put as many parameters of the same type at the end of a method - actually, the vararg parameter is just an array of elements of that type. Varargs were already present in Groovy 1.0 - and still work with a JDK 1.4 runtime, but it is good to show how you can use them. Basically, whenever the last argument of a method is an array of objects, or a parameter declaration with a triple dot, you can pass multiple parameters to this method.

A first example will show the usage of varargs in Groovy with the ellipsis:

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

The assertions used in this example show how we can pass as many ints as desired. It is also interesting to see that, for more syntax compatibility with Java, the classical for loop has been added into Groovy - despite the presence of the groovier version with the in keyword that can also transparently iterate over various array or collection types.

Note that it is possible to have varargs support even with an array as last parameter by declaring the method as follows:

int sum(int[] someInts) { /* */ }

This snippet is really trivial, and there are obviously more expressive ways of calculating a sum. For instance, if you have a list of numbers, you can sum all of them in a single line of code:

assert [1, 2, 3].sum() == 6

Varargs in Groovy don't require JDK 5 as the underlying Java runtime, unlike annotations that we are now going to look at in the following section.

### Annotations

As shown in the documentation of JBoss Seam which supports Groovy for writing its entities, controllers and components, annotations like @Entity, @Id, @Override and others can be used to decorate your beans:

@Entity@Name("hotel")class Hotel implements Serializable{     @Id @GeneratedValue     Long id      @Length(max=50) @NotNull     String name      @Length(max=100) @NotNull     String address      @Length(max=40) @NotNull     String city      @Length(min=2, max=10) @NotNull     String state      @Length(min=4, max=6) @NotNull     String zip      @Length(min=2, max=40) @NotNull     String country      @Column(precision=6, scale=2)     BigDecimal price      @Override     String toString() {         return "Hotel(${name},${address}, ${city},${zip})"     }}

The Hotel entity is marked with the @Entity annotation, and it's given a name through @Name. Different parameters can be passed to your annotations like in the @Length annotation constraint where different upper and lower bound can be set for validation purpose. You can also notice Groovy properties in action: Where are all the getters and setters? Where are the public or private modifiers? You don't have to wait for Java 7 or 8 to get properties! By convention, defining a property is as simple as String country: a private country field will be auto-generated, as well as a public getter and setter. Your code becomes naturally more concise and readable.

Annotations can be used on classes, fields, methods and method parameters, like in Java. There are, however, two gotchas to be aware of. Firstly, you can use annotations in Groovy, but you cannot yet define them - however, it will be possible in an upcoming version of Groovy. Secondly, although the syntax is almost 100% the same as in Java, there is a little difference when an array of values is passed in parameter of the annotation: instead of curly braces to surround the elements, Groovy requires the use of square brackets to offer a more homogeneous syntax - since Groovy lists and arrays use square brackets to surround their elements as well.

With annotations in Groovy 1.5, you can easily define your JPA or Hibernate annotated beans (http://www.curious-creature.org/2007/03/25/persistence-made-easy-with-groovy-and-jpa/) in Groovy, add an @Transactional annotation on your Spring services, test your Swing UI with TestNG and Fest (http://www.jroller.com/aalmiray/entry/testing_groovy_uis_with_fest). All the useful and powerful enterprise frameworks leveraging annotations can be used from your Groovy-powered projects.

### Enums

Whenever you need a fixed set of constants of a same type, Enums come in handy. Say you need a clean way to define constants for days without resorting to using integer constants? Then Enums are your friend. The following snippet shows how to define the days of the week:

enum Day {     SUNDAY, MONDAY, TUESDAY, WEDNESDAY,     THURSDAY, FRIDAY, SATURDAY}

Once you have defined your enum, you can use it as in Java with the usual notation Day.MONDAY and you can spice up your switch / case statements with it as well:

def today = Day.SATURDAYswitch (today) {     // Saturday or Sunday     case [Day.SATURDAY, Day.SUNDAY]:         println "Weekends are cool"         break     // a day between Monday and Friday     case Day.MONDAY..Day.FRIDAY:         println "Boring work day"         break     default:         println "Are you sure this is a valid day?"}

Notice that Groovy's switch is a bit more powerful than C-like languages switches in that it is possible to use any kind of object in the switch and case. Instead of stacking up seven different case block with each enumerated value, you can regroup them in lists or ranges: whenever the value is in the list or the range, the case will be true and its associated instructions will be executed.

A more complex example inspired by the Java tutorial takes a more astronomical perspective on enums, and shows how your enums can have properties, constructors and methods:

## New interactive shell and the Swing console

Groovy distributions always contained two different shells: a command-line shell as well as a Swing console. Groovysh, the command-line shell, has never been very friendly in terms of interactions with its user: whenever you wanted to execute a statement, you had to type 'go' or 'execute' after each one, so that it got executed. For quick prototyping or playing with some new API, typing 'go' each time was very cumbersome. The situation has changed in Groovy 1.5, since a new interactive shell is born. No need to type 'go' anymore.

This new shell features several enhancements, such as the use of the JLine library which provides ANSI coloring, tab completion for commands, line editing capabilities. You can work with different script buffers, remember already imported classes, load existing scripts, save the current script to a file, browse the history, etc. For detailed explanations of the supported features, please have a look at the documentation.

The command-line shell isn't the only one that received some care, the Swing console has also been improved, with a new toolbar, with advanced undo capabilities, the possibility to increase or decrease the font size, syntax highlighting. A lot of polishing has been applied to the console.

### IntelliJ IDEA JetGroovy plugin

I will save the best of tooling support till the end of this section by mentioning the JetGroovy plugin: a free and Open Source IntelliJ IDEA plugin dedicated to the support of both Groovy and Grails. This plugin has been developed by JetBrains themselves, and provides unmatched support for both the language and the web framework.

To list a few of the available features of the Groovy support:

• Syntax highlighting for all the syntax, plus different warnings for types not recognized, or when static type information is not known to help spot potential errors.
• Ability to run Groovy classes, scripts and JUnit test cases written in Groovy.
• Debugger: You can debug step by step across your Java and Groovy code, set breakpoints, show variables, the current stack, etc.
• Joint compiler: the compiler compiles both Groovy and Java classes together and is able to resolve dependencies between both languages.
• Code completion for packages, classes, properties, fields, variables, methods, keywords, and even specific support for the Swing UI builder.
• Advanced class search and find usage.
• Refactorings: most of the usual refactorings you've come to love in Java are available as well and work across Java and Groovy, like "surround with", introduce, inline or rename a variable, renaming for packages, classes, methods, and fields.
• Imports optimizations and code formatting.
• Structure view: to have a bird's eye view of your classes.

At the end of the day, you won't even notice whether you're developing a class in Groovy or in Java, considering the level of interplay and support offered inside IntelliJ IDEA. This is definitely a plugin to install if you're considering adding some dose of Groovy in your Java project, or if you plan to develop Grails applications.

Although I'm only mentioning the plugin for IntelliJ IDEA, for your Groovy developments, you don't have to change your habits. You can also use the Eclipse plugin which is regularly improved by the IBM Project Zero developers, or Sun's brand new support of Groovy and Grails in NetBeans.

## Performance improvements

Along with new features, this new release of Groovy brings noticeable performance improvements as well as lower memory consumption, compared to previous versions. In our informal benchmarks measuring the duration of all our test suites, we noticed speed improvements between 15% to 45% compared with our beta versions of Groovy 1.5 - and certainly higher figures can be expected by comparing with the now old Groovy 1.0. More formal benchmarks have yet to be developed, but those figures have also been confirmed by developers from an insurance company that is using Groovy to write the business rules of their policy risk calculation engine, and from another company who ran several tests on highly parallel machines. Overall, Groovy 1.5 should be faster and leaner in most situations. Your mileage may vary depending on your own context of usage of Groovy.

## Enhanced dynamic capabilities

Through the symbiotic relationships between the Groovy and Grails projects, new dynamic capabilities have been introduced in Groovy, after having matured in the heart of Grails.

Groovy is a dynamic language: put simply, it means that certain things like method dispatch happens at runtime, instead of at compile-time as it is the case of Java and other languages. There is a specific runtime system, called the MOP (stands for Meta-Object Protocol) that is responsible for the dispatching logic. Fortunately, this runtime system is open enough so that people can hook into the system and change its usual behavior. For each Java class and for each Groovy instance, there is an associated meta-class which represents this runtime behavior of your objects. Groovy offered various ways to interact with the MOP by defining custom meta-classes by extending some base class, but thanks to the contribution from the Grails project, a groovier kind of meta-class is available: the expando meta-class.

Again,code samples are easier to help us understand the concept. In the following example, the msg String instance has got a meta-class that we can access through the metaClass property. Then we change the meta-class of the String class to add a new method called up to the String class, to have a shortcut notation for the toUpperCase() method. To do so, we assign a closure to the up property of the meta-class which is created as we assign it the closure. This closure takes no argument (hence why it starts with an arrow), and we call the toUpperCase() method on the delegate of the closure, which is a special closure variable which represents the real object (here the String instance).

def msg = "Hello!"println msg.metaClass String.metaClass.up = { -> delegate.toUpperCase() }assert "HELLO!" == msg.up()

Through this meta-class, you can query the methods and/or properties which are available:

// print all the methodsobj.metaClass.methods.each { println it.name }// print all the propertiesobj.metaClass.properties.each { println it.name }

You can even check that a certain method or property is available, with a finer granularity than through any instanceof check:

def msg = 'Hello!'if (msg.metaClass.respondsTo(msg, 'toUpperCase')) {    println msg.toUpperCase()} if (msg.metaClass.hasProperty(msg, 'bytes')) {    println  foo.bytes.encodeBase64()}

These mechanisms are extensively used in the Grails web framework for instance to create dynamic finders: no need for DAOs in most circumstances, as you are able to call a findByTitle() dynamic method on a Book domain class. Through meta-classes, Grails automatically decorates the domain classes with such methods. Furthermore, if the method doesn't exist yet, it will be created and cached on first use. This can be accomplished by other advanced hooks as explained below.

Beyond those examples we've seen so far, expando meta-classes also provide some complementary hooks. Four other kind of methods can be added to an expando meta-class:

• invokeMethod() lets you intercept all methods calls,
• while methodMissing() will be called on last resort only of no other method is found.
• whereas propertyMissing() is called when no property can be found.

With expando meta-classes, customizing the behavior of the types of your application becomes easier and can save precious time of development compared with the previous version of Groovy. Obviously, not everybody needs to use those techniques, but they can be handy in a number of situations where you want to apply some AOP (Aspect Oriented Techniques) to decorate your classes, and when you want to simplify and make more readable the business code of your application, by removing some unnecessary boiler-plate code.

## Swing on steroids

The Groovy project has the chance to have a team of talented Swing developers who worked hard to enhance the capabilities of Groovy to build user interfaces in Swing. The basic brick for building Swing UIs in Groovy is the SwingBuilder class: at a syntactical level in your source, you can visually see how Swing components are nested within each other. A simplistic example from the Groovy website shows how to simply create a little GUI:

import groovy.swing.SwingBuilderimport java.awt.BorderLayout import groovy.swing.SwingBuilderimport java.awt.BorderLayout as BL def swing = new SwingBuilder()count = 0def textlabeldef frame = swing.frame(title:'Frame', size:[300,300]) {    borderLayout()    textlabel = label(text:"Clicked ${count} time(s).", constraints: BL.NORTH) button(text:'Click Me', actionPerformed: {count++; textlabel.text = "Clicked${count} time(s)."; println "clicked"},              constraints:BorderLayout.SOUTH)}frame.pack()frame.show()

In the novelties, the Swing builder concept has been extend to provide custom component factories. There are additional modules, not bundled with Groovy by default, which integrates the Swing components from JIDE or from the SwingX project into the usual Swing builder code.

Although this topic would deserve a full article, I'm only going to list some of the other improvements in this release, for instance, the bind() method. Inspired by the beans binding JSR (JSR-295), you can easily bind components or beans together to have them react upon changes made on each other. In the following example, the size of the insets of the button will be changed according to the value of the slider component:

import groovy.swing.SwingBuilderimport java.awt.Insetsswing = new SwingBuilder()frame = swing.frame {     vbox {        slider(id: 'slider', value:5)        button('Big Button?!', margin:             bind(source: slider,                  sourceProperty:'value',                  converter: { [it, it, it, it] as Insets }))     }}frame.pack()frame.size = [frame.width + 200, frame.height + 200]frame.show()

Binding components together is such a common task when building user interfaces, that this task has been simplified through this binding mechanism. There are also some other automatic binding options that can be used, but again, a dedicated article would probably be better.

In other new and noteworthy features, a few handy new methods have been added which leverage closures to call the infamous SwingUtilities class, and to start new threads: edt() will call invokeAndWait(), while doLater() will call invokeLater(), and doOutside() will just launch a closure in a new thread. No more ugly anonymous inner classes: just use closures through those shortcut methods!

Last but not least, separating the description of the view and its associated behavior logic has never been easier, thanks to the build() method on SwingBuilder. You can create a separate script which only contains the view, while the interactions or bindings between components are in the main class, making a clearer separation in the MVC model.

## Summary

In this article, the new and noteworthy features have been outlined, but we have barely scratched the surface of this new version of Groovy. The big highlights are mainly around the new Java 5 features, such as annotations, enums or generics: it makes Groovy perfectly capable of being integrated nicely and seamlessly with Enterprise frameworks such as Spring, Hibernate, or JPA. With the improvements in the syntax and with the enhanced dynamic capabilities, Groovy will let you customize your business logic by creating embedded Domain-Specific Languages, that you can easily integrate at the extension points of your application. The developer experience has progressed significantly through the work poured in the tooling support, this is no more a show stopper to the adoption of Groovy. Overall, with Groovy 1.5, the goal of simplifying the life of developers has never been so well fulfilled, and Groovy should definitely be part of all the Java developers' toolbox.

Guillaume Laforge is the Groovy Project Manager and the Spec Lead of JSR-241, the Java Specification Request standardizing the Groovy language among the Java Community Process. He is also the Vice-President of Technology and co-founder of G2One, Inc., the company sustaining and leading the development of the Groovy and Grails project. Guillaume regularly speaks about Groovy and Grails at various conferences, such as JavaOne, JavaPolis, the Sun TechDays, the Spring Experience, Grails eXchange.

Style

## Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

• ##### Congratulations

by Diego Pacheco,

• ##### Compilation problem with tripple dot notation of vararg

by Vimal Kansal,

• ##### Re: Compilation problem with tripple dot notation of vararg

by Guillaume Laforge,

• ##### Re: Compilation problem with tripple dot notation of vararg

by Vimal Kansal,

• ##### Re: Compilation problem with tripple dot notation of vararg

by Ryan Slobojan,

• ##### Re: Compilation problem with tripple dot notation of vararg

by Vimal Kansal,

• ##### Polymorphic variation

by Peter Bona,

• ##### calling a groovy script from groovy

by Peter Lappo,

• ##### Re: calling a groovy script from groovy

by Guillaume Laforge,

• ##### Broken link to documentation of Groovy Shell

by Michal Szklanowski,

• ##### Great Language! Great Upgrade!

by jianwu chen,

• ##### Sun should make the effort and get a good pluggin for Groovy in Netbean

by Jean-Simon LaRochelle,

• ##### Re: Sun should make the effort and get a good pluggin for Groovy in Netbean

by Boy Bawang,

• ##### Re: Sun should make the effort and get a good pluggin for Groovy in Netbean

by Joshua Gertzen,

• ##### I wished the dot ('.') in method dispatch would be optional

by Angelo Schneider,

• ##### Re: I wished the dot ('.') in method dispatch would be optional

by Dan Tines,

• ##### Congratulations

Your message is awaiting moderation. Thank you for participating in the discussion.

Guillaume,
Groovy 1.5 is awesome! Tanks for the great article.

Diego Pacheco.

• ##### Compilation problem with tripple dot notation of vararg

by Vimal Kansal,

Your message is awaiting moderation. Thank you for participating in the discussion.

I just copied and pasted the code in groovyconsole and it throws :

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

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

• ##### Re: Compilation problem with tripple dot notation of vararg

Your message is awaiting moderation. Thank you for participating in the discussion.

Well spotted! I made a last minute change in some code snippets, and it seems I had not run them all before publishing the article. Of course, the code should read

int sum(int... someInts) { }
int sum(int someInts...) { }

Sorry for this error.

• ##### Re: Compilation problem with tripple dot notation of vararg

by Vimal Kansal,

Your message is awaiting moderation. Thank you for participating in the discussion.

Thanks a lot for such a quick response. Groovy is rocking and I am in love with Groovy. Thanks a lot for giving us such a wonderful language and product.

• ##### Polymorphic variation

by Peter Bona,

Your message is awaiting moderation. Thank you for participating in the discussion.

"alternative languages which don't support strong typing, can't always call all Java methods because of the fact they can't choose a certain polymorphic variation of the same method"

Which languages are you referring to and can you maybe give an example how it can be a problem? Thanks.

• ##### calling a groovy script from groovy

by Peter Lappo,

Your message is awaiting moderation. Thank you for participating in the discussion.

Hi Guillaume,
Wikipedia says this about scripting languages "One common programming task is known as scripting, or connecting pre-existing components to accomplish a new related task".

I see you have very nice integration with Java, but does this extend to calling Groovy or indeed other external programs from Groovy. In version 1 calling a Groovy script from Groovy was ugly. Has this improved with 1.5 to something like perl or shell scripts?
result = anotherGroovyScript.groovy
or better still
result = anotherProgramme
or even
filteredResult = anotherGroovyScript.groovy | filterScript.groovy
Peter

• ##### Re: Compilation problem with tripple dot notation of vararg

Your message is awaiting moderation. Thank you for participating in the discussion.

Well spotted! I made a last minute change in some code snippets, and it seems I had not run them all before publishing the article. Of course, the code should read
int sum(int... someInts) { }
int sum(int someInts...) { }

Sorry for this error.

I've edited the article above to have the correct syntax.

• ##### Re: Compilation problem with tripple dot notation of vararg

by Vimal Kansal,

Your message is awaiting moderation. Thank you for participating in the discussion.

Thanks

• ##### Re: calling a groovy script from groovy

Your message is awaiting moderation. Thank you for participating in the discussion.

From a script, you can evaluate another Groovy script with the evaluate() method. Pass it a String or a File.

• ##### Broken link to documentation of Groovy Shell

Your message is awaiting moderation. Thank you for participating in the discussion.

Just to point out, that the link leading to the documentation of Groovy Shell is broken - one 'l' is missing at the end.

• ##### Hyperlink missing for "Groovy and Grails in NetBeans"

Your message is awaiting moderation. Thank you for participating in the discussion.

Groovy and Grails in NetBeans

Please note it should be "a href" instead of "a hef". "r" is missing. Due to this the hyperlink for "Groovy and Grails in NetBeans" does not work.

• ##### Great Language! Great Upgrade!

by jianwu chen,

Your message is awaiting moderation. Thank you for participating in the discussion.

Hope more and more Java people full in love with groovy. The design of groovy is always so elegant and creative. It provides a simple, practical and nice alternative for java people to solve various problems which is not easily solved in java language with elegant code.

Hope NetBeans IDE will come out full featured Groovy support soon. And SUN don't waste their money on a language (Ruby/JRuby) which is in totally different world. It's totally wrong decision to host Ruby language instead of Groovy in a Java IDE.

• ##### Sun should make the effort and get a good pluggin for Groovy in Netbean

Your message is awaiting moderation. Thank you for participating in the discussion.

Having a good JRuby environment is nice but I think that Sun made a mistake neglecting Groovy. Groovy needs an open source environment that is as good for Groovy as what we have for Java (refactoring, browsing, ...).
The language will not spread with the same efficiency without a good plugin in Eclipse or Netbean.
There also might be no way around building a good plugin for Eclipse because it is the most popular Java IDE. Sun will not provide this so the open source community will have to supply the effort.

• ##### Re: Sun should make the effort and get a good pluggin for Groovy in Netbean

by Boy Bawang,

Your message is awaiting moderation. Thank you for participating in the discussion.

I love Groovy as much as I want it to succeed. But it won't gain impression to serious programmers unless it changes its funny name. Yes the world "groovy" sounds funky and unprofessional!

Groovy is an improvised Java therefore it can be better recognized by the crowd if it retains the prefix java in its name. Why not Java++, JavaUltra, Java X, or even Java360 :)

• ##### I wished the dot ('.') in method dispatch would be optional

Your message is awaiting moderation. Thank you for participating in the discussion.

Well,

get rid of the necessarity of the dot and we could even write:

fund compare to: benchmarkFund, in: euroscompare fund: someFund, to: benchmark, in: eurosmonster move left: 3 meters, at: 5 mph

And if you finally reverse (optional) also the order of "noun" and "verb" we could even write:

compare fund to: benchmarkFund, in: euroscompare fund: someFund, to: benchmark, in: eurosmove monster left: 3 meters, at: 5 mph

For DSLs surely a nice to have feature.

• ##### Re: I wished the dot ('.') in method dispatch would be optional

by Dan Tines,

Your message is awaiting moderation. Thank you for participating in the discussion.

Well,

get rid of the necessarity of the dot and we could even write:

fund compare to: benchmarkFund, in: euroscompare fund: someFund, to: benchmark, in: eurosmonster move left: 3 meters, at: 5 mph

And if you finally reverse (optional) also the order of "noun" and "verb" we could even write:

compare fund to: benchmarkFund, in: euroscompare fund: someFund, to: benchmark, in: eurosmove monster left: 3 meters, at: 5 mph

For DSLs surely a nice to have feature.

That would be sweet...very Smalltalkish and even better than Smalltalk if we could do verb-noun. Maybe further down the road with AST Transformations or Macros

• ##### Re: Sun should make the effort and get a good pluggin for Groovy in Netbean

Your message is awaiting moderation. Thank you for participating in the discussion.

IMO Java & Groovy should strive to be the same language. I say this because I think that blended static/dynamic languages is the direction that things are moving.

The main quality of a blended language is that its types can either be statically defined and bound or dynamically defined and bound depending on how specific you get with your code. The benefit of this is that you can be really loose with your coding style until you feel comfortable enough with your design to lock it down formally.

Oddly, the only language that I know of that has achieved something like this is JScript.NET... but that doesn't help me or any devout Java developer. Groovy seems to be striving for something like this and that's why I'm really interested in it. I just wish that Sun would adopt the blended language philosophy and incorporate Groovy directly into Java core.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p