Comment
I'd argue that having these dynamic featured hacked on rather than being fundamental to the language like in Obj-C, Smalltalk, Ruby etc, means thatbthey aren't use as pervasively as they should be.I understand what you are saying, but C#'s flexible method dispatch, multicast events, etc. were all baked into the language from its inception. Those things that were left to the libraries were done so as a conscious design decision. Anders Hejlsberg was well aware of Smalltalk and Objective C when he designed C#. Nothing in the language feels "hacked on". The "send a message to an opaque object and hope things work out" approach of Smalltalk was replaced by flexible method dispatching and a robust, language integrated event system. C# manages to do all this with the advantages of strong typing, and without sacrificing flexibility and terseness. If you need something more "dynamic" you can use a scripting language that compiles to CIL (Ruby, Python, Javascript, etc.) or run things completely dynamically in the Dynamic Language Runtime.
Now these XML based UI languages seem to me simply a different way of failing at the same problem. They let you go in and edit by hand what a UI builder outputs. If you need to edit a UI built with a UI builder by hand then that is a failure of the UI builder.That isn't the intention, although its certainly possible. The simple XML definitions allow for easy portability between tools. Note that I like Apple's interface builder, and am in no way knocking its usability characteristics.
Obj-C does have some legacy bagage due to being built on top of C, though whether that baggage is a disadvantage is subjective. Personally I find headers to be a brilliant form of documetation.I'll take my nice, hyperlinked JavaDoc and .NET docs ;-)
Of course one other thing that Obj-C has that Java and C# don't is interspersed arguments, which greatly improves the clarity of code by making methods naturally self documenting.On this, we agree. I've been arguing for the addition of named arguments to Java for years. C# added object initializers in v3.
button.Painter = new Painter { GradientFill = new GradientFill {
ColorA = Color.FromArgb(192, 192, 255),
ColorB = Color.Navy
},
MultiBorder = new MultiBorder {
OuterBorderSize = new Padding(1),
TopOuterColor = lightBorderColor,
LeftOuterColor = lightBorderColor,
BottomOuterColor = darkBorderColor,
RightOuterColor = darkBorderColor
},
ForeColor = Color.FromArgb(255, 255, 230)
};
Martin Pilkington: The reason Apple uses Objective-C is because it is highly dynamic... That key part is message sending.I'm familiar with Smalltalk style message passing, but I don't see it as an advantage. I know Objective C messages can be intercepted, routed, delegated and sent remotely, but all of these things are supported by Java and .NET libraries via event buses, AOP interceptors and, in the case of C#, other language features. At this point, the difference between message sending and flexible method dispatching is largely academic, leaving Objective C's message orientation as nothing more than a syntactic oddity.
Martin Pilkington: This allows for a much more dynamic language, with less code needing to be written to perform simple tasks. It's this that allows for Cocoa to adopt things such as the target action paradigm. So instead of the Java way of responding to a button press by creating an ActionListener in an inner class or separate class and implementing the actionPerformed method and then adding that as an action listener to the button, you just tell the button what message to send to what object when it is pressed. In a nutshell: [myButton setTarget:self];Yes, but nobody handles event wiring procedurally these days. In the SDL/Swing framework we use, the above code would be written in a separate declarative UI definition as:
[myButton setAction:@selector(myCoolMethod:)];
button ID="myButton" do="myCoolMethod"...which would invoke a Java method in the controller called myCoolMethod().
© 2024 Created by Daniel Leuck. Powered by
You need to be a member of TechHui to add comments!
Join TechHui