Archives for October 2007

Gaming-The Next Frontier for Groovy

Create a new programming language. Check. Build a web framework around it and expand into the business app space. Check. Found a company to support the language and drive development. Check. What’s next?

Gaming. No, it’s not a typo. Hear me out at least. One of the editors at JavaLobby declared October to be Java Gaming month. It got me thinking, is there any reason why Groovy couldn’t be used for a game with a decent framework like LWJGL or jME? I know, I know. Speed, you’ll say. I’ll concede that Groovy does have some metaobject protocol issues but you are planning to use a decent timer and not iterate from one to ten thousand, right? While obviously not the best choice for something like a first person shooter, Groovy could fit well in the casual gaming market space. The games in this genre aren’t usually GPU-intensive and being able to let your users add objects and extend them with closures is quite compelling. I see Groovy’s ideal spot as a scripting extension to a current Java framework. Just a little bit to thing about...

Unofficial Debian-Ubuntu packages for Groovy

The drive to create them was sparked out of laziness and had been something I told myself I would eventually do and finally I got around to doing it. These binary packages are very basic and may not totally follow Ubuntu/Debian policy. But they install and uninstall fine, and respect dependencies.

I have packages for Gant 0.3.3-1.1, Groovy 1.0, 1.1-beta3, and 1.1-RC-1. Let me know if there are any problems though it’ll be a week before I’ll have reliable internet again(vacation). Maybe then we can setup a permanent home somewhere at The Codehaus.

Edit: The packages are up at the Codehaus.
http://groovy.codehaus.org/Download
http://groovy.codehaus.org/Gant

Enjoy!

Are Layout Managers yet another case of NIH syndrome?

Java is infamous for its multiplicity. Pick any concept and there is probably three or four APIs that do it. LayoutManagers, it seems, take this to another level. Every six months or so, someone blogs about their awesome, better mousetrap...err.. LayoutManager touting how it's going to revolutionize GUI design and solve world hunger. Because of the lack of GUI support in Netbeans for certain dynamic languages, I'm forced to code user interfaces by hand. I understand the need for a LayoutManager that is intuitive and easy to use. I just question if it is always the best use of resources to roll your own.

pMetrics is like crack, partie deux

As I mentioned in my last post, XML is one of the several formats in which pMetrics offers information from their API. My widget encloses a thin wrapper around the SwingX-WS APIs tuned for the queries that pMetrics responds to. Once retrieved, I took advantage of Groovy’s awesome XML parsing capabilities.

If you saw the demo at the Tampa JUG, you may have noticed that when I selected a date range, I selected a small one. This was mostly because each date in the range is called separately to construct a visitors over time graph. To reduce this to a one-time penalty, I added a in-process instance of HSQLDB to catch the visitor counts. This could be done for the other graphs as well but I don’t want pMetrics to come looking for me when someone decides to get data for a 31-day date range and hit their servers with over 100 requests. pMetrics, if you are reading this, help us out and put a day-by-day breakdown in your result sets.

Make sure to check out the chart node that is added at compile-time. I wanted to show how a non-Swing/non-Groovy component can integrate well into the builder:


panel(layout:new MigLayout()) {
  chart(type:’bar’, dataset:results.visitorsOverTime)
}



and here is the factory creates it:


//Chart factory
def chartFactory = [newInstance:{builder, name, value, attrs ->
  def dataSetName = attrs.remove(’dataset’)
  def options, chart, type = attrs.remove(’type’)
  if (type == ’bar’) {
    options = [false, false, false]
    chart = ChartFactory.createBarChart(’’, ’Days’, ’Visitors’, dataSetName, PlotOrientation.VERTICAL, *options)
    chart.backgroundPaint = Color.white
  }
  else {
    options = [true, true, true]
    chart = ChartFactory.createPieChart(’’,dataSetName, *options)
    chart.backgroundPaint = Color.black
  }
  return builder.widget(new ChartPanel(chart))
 }
] as groovy.swing.factory.Factory



Before you use it the first time, make sure to register it with the builder:


swing.registerFactory("chart", chartFactory)