Hi all, I wanted to collect a bit data to how you avoid boxing in your language implementations. I am asking because currently Groovy makes lots of calls via Reflection, and that means creating for each call an Object[], containing boxed values of ints and all the other primitive types. Not only that... for doing 2+3, we actually box the numbers, make a dynamic method call to Integer.plus, which then unboxes the values, makes the plus operation and boxes the result. Usually we keep the boxed value, so there is no need to unbox again, but still... for a simple plus you need to do quite a lot. And even if the call would be native.. I make measurements, that such code is 20-30 times slower, even with a direct method call.
The best thing would be of course to call the method with primitive types.. but keeping such a type information isn't the most easy thing to do. Reflective method calls do not return primitives and f(a)+g(b) might or might not be something where two ints are added. On the other hand... keeping the values on the stack isn't easy either. There are just too many primitive types to provide a path for each and every primitive type. Also longs and doubles take up two slots instead of one, making stack manipulation more difficult. I see here an advantage for interpreted languages, since thy have not to care about such things and can do whatever they need to do. And static languages do usually now the resulting types of method calls, so they won't have these problems either I guess.. John Rose was talking about tuples... but I am not sure they can be used to resolve the general problem. What do others think? bye Jochen -- Jochen "blackdrag" Theodorou The Groovy Project Tech Lead (http://groovy.codehaus.org) http://blackdragsview.blogspot.com/ http://www.g2one.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en -~----------~----~----~----~------~----~------~--~---
