Date: Mon, 19 May 2008 19:18:30 -0400
From: Andy Lee <[EMAIL PROTECTED]>

[...] When you are accessing only the public API for a class, C#'s
extension methods provide the same sort of syntax, but via static
methods that the compiler handles so as to make them look like they
are part of the original class.

Interesting.  When you say static methods, do you mean methods that
cannot access instance internals?

I mean "static" in the sense of: a method not associated with a specific object instance.

What does self (or this, or
whatever) refer to in those methods?

Nothing.  It's not valid.

As Philippe correctly pointed out, this is not quite the same as categories in Objective-C. Only code compiled with extension methods will wind up using them, and they can't do things like override existing virtual methods.

But personally, it makes me nervous to have a language that allows the implementation of a class to change according to other code not related to the class. It's one thing if you're just adding a method that you want to use somewhere else. But in Objective-C you can also add a method that overrides a base class method, or would not normally exist in the class but which has meaning to some other code that might check for it.

Powerful? Yes. But I'm reminded about the classic joke about how you shoot yourself in the foot with different programming languages. I _like_ that in C#, you can't modify an existing class, except as a syntactical shorthand.

If I had ever found myself banging my head against the wall or wasting an exorbitant amount of time trying to get around the lack of such features in other languages, I might be more inclined to find them worth the trade-off in increased ways to shoot yourself in the foot. But I haven't, so I'm not.

Obviously, other people's mileage may vary, including your own. But I really REALLY think it would be worthwhile for the existing Cocoa community, and especially the experts, to try to look at the issue from this point of view once in awhile.

I don't go around telling you guys that you're crazy for wanting to use Objective-C and even liking it. I find it condescending and abusive that rather than those who are having trouble adjusting, or who simply find the language not exactly to their liking, being offered some sympathy instead those people are basically told "well, you just haven't learned enough about Objective-C", or "you obviously don't know anything about OOP", or "only the true believers are worthy to write Mac software", or any of the numerous other variations on that theme.

And no, not all responses are long those lines. But there's certainly no shortage of those kinds of sentiments.

I can't speak for others, but for my own part, my goal isn't to convince everyone that Objective-C is bad. My goal is to try to express my own personal views of the language and why I feel the way I do, as a way of trying to get someone, _anyone_ to have just a smidgen of empathy for a person like me who does not necessarily find the Kool-Aid particularly to his liking.

And one last time: it's NOT the language that really causes me distress. The things I've spent an inordinate amount of time discussing really are minor annoyances, easily dealt with. I don't _have_ to have a safe language, I just happen to like that better.

If I could pick three things that I could change about Mac software development, and with a wave of a magic wand fix them instantly, there's nothing in Objective-C that would make that list.

Pete
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to