5 ms·
> You want to know an unpopular opinion?? I love Objective-C and I think it is better—way better than Swift. And—if you have discipline, the preprocessor is exc
by anonymouse008 5y ago
> You want to know an unpopular opinion?? I love Objective-C and I think it is better—way better than Swift. And—if you have discipline, the preprocessor is excellent.
Very curious to the reasoning here. If you can get to the pointer level of Swift, you basically have obj-c without all the unnecessary syntax?
In my view, excessive syntax is a crutch to make the language parser's job easier, not making the thought to code job easier. Obj-C seems to suffer from the excessive syntax?
- OnlyMortal 5y agoTo be fair, the syntax has changed since the days of NeXT. Accessing object variables been more C like (dot notation). Personally, I never had any difficulties understanding the old syntax.
- pianoben 5y agoIf anything, the old syntax was pure and consistent with what actually happens - message sending. Dot notation muddies the waters, IMO, but certainly is convenient. Ditto the collection literals.
- bitwize 5y agoI still say they did properties wrong. If you have a property prop, it should synthesize methods prop and prop: and expose them to the user. Then, to get you say [obj prop] and to set you say [obj prop: newVal]. This is a convention widely used in Smalltalk, and is nearly as convenient to use as dot notation. Dot notation in Objective-C makes the dot operator mean two different things; and in one case it takes a bare struct and in the other case it takes a pointer. Utterly weird. But it's a belt onion: done because it was the style at the time.
- b3morales 5y agoThis is in fact how @property works; the declaration is sugar for a pair of accessor methods. The dot syntax is sugar for calling those methods. #include <Foundation/Foundation.h> @interface Foo : NSObject @property (copy) NSString *bar; @end @implementation Foo @end int main(int argc, char *argv[]) { Foo *foo = [Foo new]; [foo setBar:@"Hello, world!"]; NSLog(@"%@", [foo bar]); return 0; }
- mucholove 5y agoThe dot syntax makes it difficult to parse whether you are dealing with a C struct or an Objective-C object. Objective-C was grafted onto C with very clear demarcation lines. We don’t mind being able to declare a property with `@property`. We do mind that they introduced dot syntax
- b3morales 5y agoSame here, I was never a proponent of the dot syntax. As we know, compiler development at Apple got taken over at some point by C++ people, and we can all see the results: https://blog.metaobject.com/2014/06/remove-features-for-greater-power-aka.html https://blog.metaobject.com/2014/06/remove-features-for-grea...
- xkriva11 5y agot.rotate (a, v); // Original t rotate (a, v); // Who needs dot? t rotate a, v; // Who needs brackets? t rotate by: a around: v; // Who needs ambiguity? t rotateBy: a around: v // This is Smalltalk
- anonymouse008 5y agoI’m rolling — this is perfect. Civilization has used dot notation in basically all thought, as evidenced by pretty much any nation’s laws / code
- gcasa 5y agoWhich of course means it's in no way ambiguous or overly used. One syntax for one purpose. Until dot notation was used for @property you never had to guess if you were looking at a structure or at a class. See how that works?
- mucholove 5y agoGreg—the funny thing is that the comment I read the comment where they explain notation differences as sort of saying that Smalltalk is the best thing on the planet and we should all aspire to be Smalltalk. No ambiguity with Smalltalk which is of course the whole point of readable, paintable code. The most easily maintainable code is that which does not need documentation. On Smalltalk: Objective-C of course aspires to be Smalltalk. It just so happens that it's happy to be a muggle and integrate C as well. Good for us. Use Smalltalk for most things and C where necessary.
- pianoben 5y ago> In my view, excessive syntax is a crutch to make the language parser's job easier, not making the thought to code job easier. Obj-C seems to suffer from the excessive syntax? Another perspective is that the syntax of Obj-C exposes and supports the core model of the language, which is objects sending messages to each other. That it happens to be fast to parse seems secondary, and certainly further developments since version 2.0 have made parsing slower, not faster. In my experience people complain about Obj-C syntax when what they actually dislike are verbose Cocoa/Foundation/etc APIs. Try their C Core* equivalents and you'll find you probably dislike those, too.
- setpatchaddress 5y ago> In my experience people complain about Obj-C syntax when what they actually dislike are verbose Cocoa/Foundation/etc APIs If so, that’s a real shame. Foundation may be the single best-designed standard library for a (non-functional) language ever.
- pianoben 5y agoI agree, Foundation is a gem! The method naming is one of the assets - the names are clear, regular, and usually fairly obvious. The downside to that regularity and clarity is that the names are long. One CoreFoundation example at random: CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef ref); I think nearly everyone who reads that prototype will immediately understand what it does, but there's no denying it's a mouthful. Tack on some unfamilar square-brackets and intersperse argument names, and it's understandable that people will conflate the syntax with the APIs.
- gcasa 5y agoCoreFoundation is not written in ObjC, it's C only (although toll-free bridged).
- bvrmn 5y agoFor me Foundation lacks composability. This method should be really two: CreateCopy (I assume it already exist) and mutating DeleteLastPathComponent. I don't mention immutable by default behavior because it was long ago and written in C.
- apple4ever 5y agoI love the expressiveness of Obj-C, I love the brackets, and I love how easy it is to write. I hate Swifts boiler plate words (var, let [why not const???], func), I hate the obtuseness of it (eg question marks everywhere), and I hate how hard it is to read because it makes it very easy to be so "clever".