jastrachan | 9 Jul 11:31 2004

Re: Groovy incompatibility with Java

On 9 Jul 2004, at 10:13, Andrew Ferguson wrote:
> hi,
>  since you seem extremely open to constructive criticism.. :)
>> Perhaps we'll add some more Java "compatibility"
> the one thing that would most likely get me using groovy in production 
> code (sooner rather than later) is if groovyc produced (or had the 
> option to produce) .class files (or maybe even java source code?) that 
> didn't require any redistributables to execute. I don't know how 
> realisitic this is, and if the only way of doing it was equivalent to 
> "generating" the pre-written runtime in the groovyc output directory 
> then that's probably not worth looking into

Unfortunately we really can't generate bytecode with no dependency on 
the groovy runtime. e.g. we use various classes in groovy.lang.* to 
implement core language features (MetaClass for dynamic method 
dispatch, Closure, Range) and so we do need to ship a groovy runtime 
with the generated bytecode. Though its just a jar to add to your 
classpath - its not the end of the world.

Who knows, this Groovy runtime could one day sneak into the JRE/JDK :). 
Failing that, its just a jar on your classpath. If the jar size is a 
real issue I'm sure we could investigate making a super-small 
dependency jar.

>> LOL :-) I don't think it may become an obscure code contests :-))
> I've not delved that deeply into groovy yet, but one thing I saw on 
> the presentation slides was that you could refer to the end of an item 
> in an array (or maybe list) by using negative indices. This is surely 
> the kind of thing that obscure code contests rely on?

Not really - its very common & useful in languages like ruby & python - 
its very common to want to look at the last, or last-but-one item in a 

> I think its because it's a special case that would surprise java 
> programmers and maybe only caters for a minority need (?), which seems 
> in contrast to the concise way of allowing access to Get/Set methods 
> without typing the full name?

If you want to be careful & strict and avoid scripty goodness, you can 
still use the regular Java List.get(int) method which doesn't allow 
negative indices.