Friday, November 30, 2007

Groovy equivalence to Chapel's code

Ability to have our own DSL in Groovy makes it possible to have a high-level language for parallel computing. I'm trying to clone all features of Chapel to Groovy and then optimise the generated codes to make it run (I hope) fast.

int n = 1000
def A = new Vector(size: n)
def B = new Vector(size: n)
forall(2..n-1) { i ->
B[i] = ((A[i-1] + A[i+1])) / 2

Tuesday, November 13, 2007

Hello Android, Are you wanting to sit on Grails?

Google's released Android SDK yesterday. After quick skimming on packages supported by the SDK, here what I can summarise,
- android packages, UI + 2D + 3D, SAX, DB, device APIs, OS calls
- java packages, java.nio, and java.concurrent (including atomic)
- httpcli
- JSON support
- cryptography, SSL
- Bluetooth support
- Google Map APIs

It seems to be not Java ME packages, but likely the striped down version of Java SE. So I think this could be possible to make quite complicate applications.
My first try here is not about making an app, but I'll see if I can have some templates to generate Grails scaffolding for it. If this can be done in a month, a full-blow application with Grails as a back-end will be easily developed. And it's going to be a big boosting up.

Wednesday, November 07, 2007

Does Grails need a real compiler?

We all know what a DSL is, so what's about a domain specific compiler (DSC)?

I've just accidentally seen Grails 1.0-RC1's been invoking its compiler during my work. So I think it's possible to have a DSC to support Grails in someway. It could be definitely based on the Groovy compiler with addition Grails knowledge. For example, in a Grails controller, we can use "render" method to render things like XML, JSON. What if we can compile this render block into a real XML, or JSON chunk embedded in the controller, rather than invoking the dynamic method.

In the development time, we've got Grails running fine and it offers us a great rapid environment. So we just keep using the original Groovy here. And if we have DSC, and it works just before grails war, then our Grails apps performance will be really great during its execution.

Sunday, November 04, 2007

Convention over Configuration for Map-Ruduce

I'd just like to have a quick look to Hadoop's word-count example, if it can be written in Groovy.

Disclaimer: this code doesn't work !

class WordCountMapReduce {
def map = {key, value, output, reporter ->
def line = value.toString()
def itr = new StringTokenizer(line)
while(itr.hasMoreTokens()) {
output.collect(word, one)

def reduce = {key, values, output, reporter ->
int sum = 0;
values.each {
sum += it.get()
output.collect(key, sum)


It's time for Groovy to go fore massive computation?