62 messages in org.codehaus.groovy.devRe: [groovy-dev] Groovy performance: ...
FromSent OnAttachments
Alex TkachmanFeb 19, 2008 2:09 am 
Steven DevijverFeb 19, 2008 2:37 am 
Alexandru Popescu ☀Feb 19, 2008 2:57 am 
Alex TkachmanFeb 19, 2008 3:03 am 
Patric BechtelFeb 19, 2008 3:12 am 
Guillaume LaforgeFeb 19, 2008 3:25 am 
Guillaume LaforgeFeb 19, 2008 3:26 am 
Patric BechtelFeb 19, 2008 5:05 am 
Gavin GroverFeb 19, 2008 5:51 am 
Steven DevijverFeb 19, 2008 5:52 am 
Guillaume LaforgeFeb 19, 2008 5:54 am 
Tom NicholsFeb 19, 2008 6:26 am 
Alex TkachmanFeb 19, 2008 6:28 am 
Guillaume LaforgeFeb 19, 2008 6:35 am 
Tom NicholsFeb 19, 2008 7:03 am 
Guillaume LaforgeFeb 19, 2008 7:38 am 
Chanwit KaewkasiFeb 19, 2008 7:52 am 
Charles Oliver NutterFeb 19, 2008 8:49 am 
Steven DevijverFeb 19, 2008 10:03 am 
Charles Oliver NutterFeb 19, 2008 11:38 am 
Steven DevijverFeb 19, 2008 12:11 pm 
Alex TkachmanFeb 19, 2008 12:39 pm 
Alex TkachmanFeb 19, 2008 12:48 pm 
tugwilsonFeb 19, 2008 1:36 pm 
Alex TkachmanFeb 19, 2008 8:51 pm 
Guillaume LaforgeFeb 20, 2008 2:10 am 
Jochen TheodorouFeb 20, 2008 9:46 am 
Martin C. MartinFeb 20, 2008 5:25 pm 
Guillaume LaforgeFeb 21, 2008 1:35 am 
Tom NicholsFeb 21, 2008 4:15 am 
Martin C. MartinFeb 21, 2008 5:44 am 
Tom NicholsFeb 21, 2008 6:22 am 
Smith, Jason, CTR, OASD(HA)/TMAFeb 21, 2008 6:34 am 
Martin C. MartinFeb 21, 2008 6:43 am 
Guillaume LaforgeFeb 21, 2008 6:48 am 
Guillaume LaforgeFeb 21, 2008 7:04 am 
Smith, Jason, CTR, OASD(HA)/TMAFeb 21, 2008 7:18 am 
Charles Oliver NutterFeb 21, 2008 7:38 am 
Guillaume LaforgeFeb 21, 2008 7:42 am 
Martin C. MartinFeb 21, 2008 8:36 am 
Martin C. MartinFeb 21, 2008 8:48 am 
Pascal DeMillyFeb 21, 2008 5:35 pm 
Gavin GroverFeb 21, 2008 6:21 pm 
Jochen TheodorouFeb 22, 2008 4:31 am 
Tom NicholsFeb 22, 2008 4:49 am 
Charles Oliver NutterFeb 22, 2008 11:43 pm 
Guillaume LaforgeFeb 23, 2008 12:28 am 
Martin C. MartinFeb 23, 2008 3:51 am 
Jochen TheodorouFeb 23, 2008 2:49 pm 
Jochen TheodorouFeb 23, 2008 2:53 pm 
Charles Oliver NutterFeb 24, 2008 2:01 am 
Martin C. MartinFeb 24, 2008 3:56 am 
Martin C. MartinFeb 24, 2008 4:11 am 
Charles Oliver NutterFeb 24, 2008 5:12 am 
Jochen TheodorouFeb 24, 2008 3:17 pm 
Jochen TheodorouFeb 24, 2008 3:31 pm 
Alexandru Popescu ☀Feb 24, 2008 3:36 pm 
Martin C. MartinFeb 26, 2008 2:20 pm 
Martin C. MartinFeb 26, 2008 3:15 pm 
Jochen TheodorouFeb 27, 2008 2:38 am 
Jochen TheodorouFeb 27, 2008 3:03 am 
Martin C. MartinMar 2, 2008 5:21 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [groovy-dev] Groovy performance: what to doActions...
From:Jochen Theodorou (blac@gmx.org)
Date:Feb 27, 2008 2:38:28 am
List:org.codehaus.groovy.dev

Martin C. Martin schrieb:

Jochen Theodorou wrote:

Martin C. Martin schrieb: [...]

Actually, we have static typing in Groovy:

def foo (String s) {1} def foo (Object o) {2}

String a = "test" Object b = a def c = a def d = b

// with Groovy style static typing assert foo(a) == 1 assert foo((Object)b) == 2 assert foo(c) == 2 assert foo((Object)d) == 2

are you sure? This should be:

assert foo(a) == 1 assert foo((Object)b) == 2 assert foo(c) == 1 assert foo((Object)d) == 2

You're right; my 7 month old kid still wakes up twice in the middle of the night, and the sleep deprivation is affecting me. :)

ah, the kid will grow and sleep through, and then he will give you other problems where you wish it would be only a matter of sleeping through ;)

[...]

yes, what you said about "a=23" is true, but what is the point? Groovy compiles "a=23" as "a=(T)23", where T is the type of a, as long as the type is known.... which means for example, that for properties no cast happens.

It wasn't a big point, just that the declaration of "a" affects the semantics of "a = 23." One of Guillaume's concerns with including a keyword/annotation for static typing was that we'd get posts to mailing lists that an expression had unexpected results, and we'd have to guess to ask them about the declaration of the variables. I'm just pointing out, we have the same issue already with "def" vs. typed variables. It's a minor point.

yes, that's true.

2. Could we use the existing syntax to do more at compile time and less at runtime? I think the answer at the moment is "no," because the types are just given to the metaclass, and in general its an uncomputable problem to tell what the metaclass will be at compile time.

do less at runtime and do more at compile time of what exactly? A method selecton? Yes, I am positivce we can let the compiler guess the method... or in other words let the compiler guess the initial method used ofr the call site cache. But in general return types andtypes of properties are unknown, so the compiler can't really do much more than guessing in many cases.

Are there cases where you could skip runtime method selection entirely, since you know it at runtime?

If the compiler guesses a method, then we have to validate that guess, not only because the guess might be wrong, but also because the MetaClass might have changed and that change could affect the current method selection... well and because a category could be active, overwriting the call we originally wanted to do.

But what if the programmer could annotate a class to say "all instances of a given class use the same metaclass," and then have a way for the metaclass to tell the compiler when a method could be determined at compile time?

let us make this more easy by making it more special. Let us say there is a way to say that always the default MetaClass will be used for all objects. In that case we could for final classes and if all types of all parameters are known generate a static call without loosing semantic. final because of our multi methods. With this it can be can be considered as rare case.

That sounds great. Do you think this is worth implementing, or would the case be too rare? Also, would the classes need to be final if mixed with the casting syntax as above? I think this could lead to its use in cases that are a lot less rare.

there is another class of methods that could theoretically be called directly and that is private methods. And I think implementing this for private methods is worth it, the implementation for other methods would be a side product then. Ah yes.. not the method needs to be final, the class needs to be, because this way we can be sure there will be no subclass adding a method... but I guess we can't work around the check here too.. because it is always possible, that the MetaClass got a new overloading or replacing method.... so this check has to check at last the MetaClass for being the default.

bye blackdrag

-- Jochen "blackdrag" Theodorou The Groovy Project Tech Lead (http://groovy.codehaus.org) http://blackdragsview.blogspot.com/ http://www.g2one.com/

--------------------------------------------------------------------- To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email