I just spent an hour playing with Groovy, and I have to say that it is very promising. I have not experimented a whole lot with the actual Groovy syntax, but based on what I have read as well as on my limited experiments, Groovy is a nice mixture of popular scripting languages such as Ruby or Python, but geared towards Java programmers. The syntax borrows many useful elements from other scripting elements but remains similar enough to Java to enable Java developers to easily learn this language. Most importantly, it provides full access to the Java class library and therefore does not require Java developers to learn yet another proprietary class library.

Groovy is extremely easy to embed into Java applications, and I am sure this will come in handy. One obvious application of this feature are computer games, which often utilize an embedded scripting language to control the behavior.

One thing I have always been interested in, even though I never ended up actually doing it (like so many things), is to write an RPG, such as a MUD or a Roguelike. If I was to start on such a project now, I would definitely use Groovy as the embedded scripting language. One main application for Groovy in this context would be the behavior of NPCs or certain objects. The way I envision this, objects and NPCs should be data driven, and they might be defined in XML files. Such an XML file might look like this:

<pre> <npc id="grompf" class="Orc"> <name>Grompf</name> <description>An ugly looking, smelly guy<description> <stats> <hp>40</hp> <str>19</str> ... other stats ... </stats> <behavior> <on-sight>[groovy script goes here]</on-sight> <on-attack>[groovy script goes here]</on-attack> ... other behavior ... </behavior> </npc> </pre>

The game engine would parse this XML file, instantiate a new object of type Orc (which itself might be defined in an XML file and might inherit from a Java class called Monster), and set the specified stats as well as the Groovy event handlers. Unspecified properties or event handlers would inherit from the parent class, such as Orc in this case.

Anyway, at this point I’m getting away from the original topic and more into game design, so I’ll leave it at this for now. :)

Definitely worth playing with.