473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Clarification of JavaLive delegates criticism?

Back when the new J2SE1.5 features were announced, there was a
JavaLive community chat
(http://java.sun.com/developer/commun...03/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't tell if he means overriding delegates
themselves. I would 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 would look like.
3) What is so significant about this problem.

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

Thanks,
Jeff
Jul 17 '05 #1
6 2252
JTK
Jeffrey T. Smith wrote:
Back when the new J2SE1.5 features were announced, there was a
JavaLive community chat
(http://java.sun.com/developer/commun...03/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 doesn't, and now has to come up with a psuedo-technical
reason for not implementing them to feed to the Java "Community Process".
Jul 17 '05 #2
JTK wrote:
Sure: Sun has taken a stance that "Delegates are Bad" because C# has
them and Java doesn't, 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 has nothing 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
Jul 17 '05 #3
> Look at http://java.sun.com/docs/white/delegates.html for an explanation of
Sun's viewpoint.


Thanks, I've already read this and MS's response at
http://msdn.microsoft.com/vjsharp/pr...h/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 would
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 aren't perfect, but what is Sun's excuse that first
class functions -can't- be done elegantly in this environment?
Jul 17 '05 #4
On 23 Jun 2004 08:38:29 -0700, Ge*******@netscape.net (Jeffrey T.
Smith) wrote 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 is not 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 would
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.
Jul 17 '05 #5
JTK
Jeffrey T. Smith wrote:
Look at http://java.sun.com/docs/white/delegates.html for an explanation of
Sun's viewpoint.

Thanks, I've already read this and MS's response at
http://msdn.microsoft.com/vjsharp/pr...h/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 would
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 aren't perfect, but what is Sun's excuse that first
class functions -can't- be done elegantly in this environment?


Again, Sun's excuse is "Microsoft did it before we did".
Jul 17 '05 #6
JTK wrote:
Jeffrey T. Smith wrote:
Look at http://java.sun.com/docs/white/delegates.html for an
explanation of Sun's viewpoint.


Thanks, I've already read this and MS's response at
http://msdn.microsoft.com/vjsharp/pr...h/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 would
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 aren't perfect, but what is Sun's excuse that first
class functions -can't- be done elegantly in this environment?

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


I don't 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 doesn't make
Java more complicated/poorer!" Well, I say it does, and the same logic
applies to delegates as well.
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sam | last post by:
I’m just starting to learn delegates. I’m at the very beginning. If I understand correctly, delegates are for when you want to pass a function as a parameter. For example the client provides a...
2
by: Marcos Stefanakopolus | last post by:
In C# is there any way to use the concept of delegates to have multiple implementations of a particular block of code, so that you can choose between them without the overhead of possibly expensive...
62
by: Xah Lee | last post by:
Criticism versus Constructive Criticism Xah Lee, 2003-01 A lot intelligent people are rather confused about criticism, especially in our “free-speech” free-for-all internet age. When they...
4
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, below is an excerpt from an article i'm currently reading. the article is about using WebUserControls and encapsulation. "Although it is possible to subscribe to the button click event...
6
by: =?Utf-8?B?Sko=?= | last post by:
I have a logger component that logs to multiple sources, ie textfile, eventlog etc. and I have two methods that depending on where I call up my logger comp. one of them will be called. For ex. if...
0
by: bharathreddy | last post by:
Delegates Here in this article I will explain about delegates in brief. Some important points about delegates. This article is meant to only those who already know delegates, it will be a quick...
6
by: =?Utf-8?B?T2xkQ2FEb2c=?= | last post by:
My question is regarding the use of delegates in C#. I see how .Net uses delegates to wire event handlers to events. It’s an object created by a single line of code by the system and that makes...
7
by: Siegfried Heintze | last post by:
I'm studying the book "Microsoft Visual Basic.NET Language Reference" and I would like some clarify the difference between events and delegates. On page 156 I see a WinForms example of timer that...
69
by: raylopez99 | last post by:
They usually don't teach you in most textbooks I've seen that delegates can be used to call class methods from classes that are 'unaware' of the delegate, so long as the class has the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.