jastrachan | 3 Jul 03:16 2004

Re: Use Groovy to bridge services and UI

On 1 Jul 2004, at 16:44, Mark Chu-Carroll wrote:
> On Thu, 1 Jul 2004 08:10:52 -0700, Andy Depue <andy@...> 
> wrote:
>> Hello,
>>   My main question is this: if I have some Java code that passes a 
>> POJO to a
>> Groovy script which then calls into the POJO and retrieves a plain 
>> Java List
>> as a return value, maybe executes some logic against the List, and 
>> returns it
>> back to the Java code that executed the script - will Groovy feel the 
>> need to
>> wrap the List or the contents of the List in some kind of Groovy 
>> wrapper?  In
>> other words, if the List contains 5000 items, will Groovy instantiate 
>> 5000
>> additional objects of some sort?  I want to use Groovy as a bridge 
>> (or glue)
>> between my rich UI and backend services, and want to make myself 
>> aware of any
>> overhead Groovy might introduce to the equation.
> No, Groovy will not wrap the list, or any members of the list.

Agreed - Groovy operates directly on any old Java object - there's no 
wrapping or adapters like there are with some other scripting 

> It will
> use the Groovy dynamic
> method invocation system, so you'll see a performance hit relative to
> writing in plain
> Java - but only for the part written in Groovy. (Meaning, if you call
> some fairly
> complex Java method, once it enters the Java method, Groovy is
> completely out of the picture, so it will run just as fast as if it
> were called directly from Java. But if your
> groovy code contains, say, a tight inner loop that calls a method on
> each of the 50,000
> items in the list, you will pay for the dynamic invocation of 50.000
> methods. It's not *that*
> expensive, because Groovy dynamic invocation isn't that slow, but it
> is still a real factor.)
> If I can just find some free time to finish it, I'm working on a
> change that will eliminate
> the dynamic method invocation performance hit when types are declared.
> Unfortunately,
> my real job has been very demanding lately, and by the time I get home
> at night, I'm
> too tired to try to figure out the remaining tricky part of this 
> change.

Sounds fantastic :). Here's hoping you're day job quietens down a 
little real soon :)

BTW did you get my gmail invite?