Sagewire Logo

Clarification of JAVALive delegates criticism?

7 Message(s) by 5 Author(s) originally posted in java misc


From: Geiger581 Date:   Monday, June 21, 2004
Back when the new J2SE1.5 features were announced, there was a
JAVALive community chat
(http://JAVA.sun.com/developer/community/chat/JAVALive/2003/jl0729.html)
in which Neal Gafter explains the Sun stance on lack of support for
delegates:

... There are serious semantic problems with trying to add delegates
to a language in a consistent way. The main problem is that once you
call the delegate, the original class instance is no longer part of
the call chain, so overriding in the original class no longer takes
precedence over the delegate. ...

Could someone please explain this to me a little more fully? It
sounds like he's saying that delegates cannot follow a subclass call
chain if they are created from an object stored in a superclass
reference, but I can not tell if he means overriding delegates
themselves. I'd like to know:
1) What exactly does he mean in less ambiguous terms? (Or maybe just
simpler terms; it's been a while since my college programming
languages course.)
2) What an example of delegates 'failing' like this'd look like.
3) What is so significant about this problem.

I am already familiar with the 'Truth about Delegates' dialogue
between Sun and Microsoft and the lack of true type safety of C# delegates,
but not understanding this criticism bothers me. Any help'd be
greatly appreciated.

Thanks,
Jeff


From: JTK Date:   Tuesday, June 22, 2004
wrote in message :

Back when the new J2SE1.5 features were announced, there was a
JAVALive community chat
(http://JAVA.sun.com/developer/community/chat/JAVALive/2003/jl0729.html)
in which Neal Gafter explains the Sun stance on lack of support for
delegates:
... There are serious semantic problems with trying to add delegates
to a language in a consistent way. The main problem is that once you
call the delegate, the original class instance is no longer part of
the call chain, so overriding in the original class no longer takes
precedence over the delegate. ...
Could someone please explain this to me a little more fully?



Sure: Sun has taken a stance that "Delegates are Bad" because C# has
them and JAVA does not, and now has to come up with a psuedo-technical
reason for not implementing them to feed to the JAVA "Community Process".


From: Christophe Vanfleteren Date:   Wednesday, June 23, 2004
wrote in message:

Sure: Sun has taken a stance that "Delegates are Bad" because C# has
them and JAVA does not, and now has to come up with a psuedo-technical
reason for not implementing them to feed to the JAVA "Community Process".



You've got your timetable screwed up. Sun has always opposed delegates in
JAVA. This already started in the days that Microsoft implemented them in
their version of the 1.1 JVM (J++) and so hasn'thing to do with C#.

Look at http://JAVA.sun.com/docs/white/delegates.html for an explanation of
Sun's viewpoint.

--
Kind regards,
Christophe Vanfleteren


From: Geiger581 Date:   Wednesday, June 23, 2004
Look at http://JAVA.sun.com/docs/white/delegates.html for an explanation of
Sun's viewpoint.



Thanks, I have already read this and MS's response at
http://msdn.microsoft.com/vjsharp/productinfo/visualj/visualj6/technical/articles/general/truth/default.aspx
. However, neither address the issue brought up at the far more
recent JAVALive talk. It seems to me like Sun is claiming that not
only is the C# implementation flakey (with which I definitely agree),
but that having delegates in a purely OO language (as a true partial
closure covering a single object) in an OO manner is something that no
one has figured out how to do in a consistent manner. C# delegates
act more like typedefs thans objects, and a 'true' delegate'd
probably behave more like a single-method interface, supporting
inheritance, true type safety, etc. They are conceptually ideal when
using event handling (i.e., associating sets of methods with
individual objects), while JAVA is both visually and conceptually
clunky, but are really still broken in a lot of ways. I realize that
C#'s delegates are not perfect, but what is Sun's excuse that first
class functions -can not- be done elegantly in this environment?


From: Roedy Green Date:   Wednesday, June 23, 2004
On 23 Jun 2004 08:38:29 -0700, Geiger581@xxxxxxxxxxx (Jeffrey T.
wrote in message or quoted :

. However, neither address the issue brought up at the far more
recent JAVALive talk. It seems to me like Sun is claiming that not
only is the C# implementation flakey (with which I definitely agree),
but that having delegates in a purely OO language (as a true partial
closure covering a single object) in an OO manner is something that no
one has figured out how to do in a consistent manner.



The complaint isn't with the inner class/delegate implementation that
JAVA uses, just that it requires so much typing for simple cases.
This obscures what is happening. If you simply invented some syntatic
sugar that amounted to a macro to generate the bubblegum, you'd
satisfy most people.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The JAVA Glossary.


From: JTK Date:   Thursday, June 24, 2004
wrote in message:
Look at http://JAVA.sun.com/docs/white/delegates.html for an explanation of
Sun's viewpoint.
Thanks, I have already read this and MS's response at
http://msdn.microsoft.com/vjsharp/productinfo/visualj/visualj6/technical/articles/general/truth/default.aspx
. However, neither address the issue brought up at the far more
recent JAVALive talk. It seems to me like Sun is claiming that not
only is the C# implementation flakey (with which I definitely agree),
but that having delegates in a purely OO language (as a true partial
closure covering a single object) in an OO manner is something that no
one has figured out how to do in a consistent manner. C# delegates
act more like typedefs thans objects, and a 'true' delegate'd
probably behave more like a single-method interface, supporting
inheritance, true type safety, etc. They are conceptually ideal when
using event handling (i.e., associating sets of methods with
individual objects), while JAVA is both visually and conceptually
clunky, but are really still broken in a lot of ways. I realize that
C#'s delegates are not perfect, but what is Sun's excuse that first
class functions -can not- be done elegantly in this environment?



Again, Sun's excuse is "Microsoft did it before we did".


From: Peter Ammon Date:   Friday, June 25, 2004
wrote in message:

wrote in message:
Look at http://JAVA.sun.com/docs/white/delegates.html for an
explanation of Sun's viewpoint.



Thanks, I have already read this and MS's response at
http://msdn.microsoft.com/vjsharp/productinfo/visualj/visualj6/technical/articles/general/truth/default.aspx

. However, neither address the issue brought up at the far more
recent JAVALive talk. It seems to me like Sun is claiming that not
only is the C# implementation flakey (with which I definitely agree),
but that having delegates in a purely OO language (as a true partial
closure covering a single object) in an OO manner is something that no
one has figured out how to do in a consistent manner. C# delegates
act more like typedefs thans objects, and a 'true' delegate'd
probably behave more like a single-method interface, supporting
inheritance, true type safety, etc. They are conceptually ideal when
using event handling (i.e., associating sets of methods with
individual objects), while JAVA is both visually and conceptually
clunky, but are really still broken in a lot of ways. I realize that
C#'s delegates are not perfect, but what is Sun's excuse that first
class functions -can not- be done elegantly in this environment?
Again, Sun's excuse is "Microsoft did it before we did".



I do not see where Sun says that. Rather, they point out that delegates
complicate the language, and claim it's not worth the cost. I'm
sympathetic to that position. Lots of things about delegates are very
confusing to me, and the more I read the more confused I become. For
example, "The invocation list of a delegate is an ordered set of
delegates in which each element of the list invokes exactly one of the
methods invoked by the delegate." Huh? And there's "delegate
arithmetic," and an inability to derive from them...

Microsoft's response to the weird semantics of delegates seems to be
"JAVA has weirdness too, like arrays and strings, and that does not make
JAVA more complicated/poorer!" Well, I say it does, and the same logic
applies to delegates as well.



Next Message: Dynamic invocation of web services?



Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional