Earlier quoted context omitted.
Consider toying around with Objective-C. I was pleasantly surprised. I had never used SmallTalk, and I had a good time with the idea of "message passing". This doesn't take away the requirement of having to own a Mac, so it's free to try it out anyway. If you have already tried it out and hate it, then I'm glad there is a new option!
I've been doing Objective-C for a long time, and I can barely stand the language. I use it because it's the most pragmatic choice for Mac (and now iPhone) development, but if I could I'd have dropped it in a heartbeat. It's incredibly verbose and almost the antithesis of "don't repeat yourself" -- as an arbitrary example, declaring an Objective-C 2.0 properties requires three different declarations: 1) Declare the in…
The equivalent ObjC code is:
IBOutlet UIWindow *window;
IBOutlet UILabel *label;
Also, your example isn't quite accurate. With the iPhone runtime, you only have to make the @property declaration in your interface and then @synthesize the variable in your implementation. #1 in your example isn't required. However, the Mac runtime doesn't support this — so by doing this, you're limited to only testing on a physical device (iPhone or iPod directly). Stick this class into a .m and compile it in Xcode targeting your iPhone and the Simulator respectively: @interface Foo : NSObject {
// id bar; // Only required on Mac runtime or if you want to use the iPhone Simulator
}
@property (nonatomic, retain) id bar;
@end
@implementation Foo
@synthesize bar;
- (void) doSomethingWithBar {
self.bar = @"baz";
NSLog (@"%@", self.bar);
}
@end
@synthesize is useful to have because, well, what if you want @dynamic?As for the rest of the verbosity? To take a canonical example,
string = [someString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
is much clearer to me then string.strip();
Or is there another example of its verbosity that you don't like? I don't find myself writing code that repeats itself very often. If I do, I'll refactor the code.And I like that it has a tendency to have explicit method names: I can actually read my code months later when I need to go fix a bug. But thats my personal preference. If you disagree, its not my place to tell you otherwise.