473,748 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2289
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*******@netsc ape.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
397
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 custom function to be called in a provider class. My confusion is that you can already achieve this by interfaces and objects without delegates (which have a little more complicated syntax) Here is an example without delegates. class Class1 and...
2
1581
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 if() or switch() logic, and without the overhead of a function call? As an example, consider the task of resizing a bitmap from size X1,Y1 to size X2,Y2 (may be shrunk or expanded, may or may not maintain aspect ratio). Code that handles the...
62
3924
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 say “constructive criticisms are welcome” they mostly mean “bitching and complaints not welcome”. Rarely do people actually mean that “criticism without suggestion of possible solutions are not welcome” or “impolite criticism not...
4
1345
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 from the containing page, doing so would break some of the object oriented rules of encapsulation. A better idea is to publish an event in the user control to allow any interested parties to handle the event. " What does it mean to subscribe to...
6
2635
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 I throw an exception I want to call one method and if I dont, I am just logging some info to eventlog, I will call the other. Now i'm wondering would it make sense to use delegates, one for each method to call methods in my window service? How...
0
4772
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 review not a detailed one. Delegates quite simply are special type of object, a delegate just contains the details of a method. One good way to understanding delegates is by thinking of delegates as something that gives a name to a method...
6
2661
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 perfect sense to me. I understand that there is a lot of code underneath that the system has created that makes it all work, thereby making it pretty efficient for the programmer. Outside of the use of delegates to wire event handlers, you can...
7
3420
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 uses the "WithEvents" and events. There is another example on page 124 that shows how to use delegates to sort an array. I don't understand the difference between events and delegates. Are they redundant features? How do I decide which to use? ...
69
5584
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 signature for the method (i.e., as below, int Square (int)). Here is an example to show that feature. Note class "UnAwareClass" has its methods Square and Cuber called by a class DelegateClass. This is because these methods in UnAwareClass have the...
1
9326
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8245
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.