4 ms·
He is at the first stage of Cocoa development. Learning a new language is fun, and you can create some really cool stuff with the Cocoa frameworks. But once tha
by probablycorey 16y ago
He is at the first stage of Cocoa development. Learning a new language is fun, and you can create some really cool stuff with the Cocoa frameworks. But once that wears off you are left with Objective-C, a vestigial language that isn't suited for a majority of application development.
Here are some reasons I think Objective-C needs to be retired:
- Header Files: These are archaic and require you to repeat code unnecessarily. Compiler's shouldn't require humans to do something that computers are better at.
- No Automatic Garbage Collection: In ObjC 2.0 we have this, but not on the iPhone. Unless you are making a high performance game, there is no reason the phone can't handle Automatic GC.
- No NSDictionary/NSArray literals: [[NSDictionary alloc] initWithObjectsAndKeys:@"value", @"key", @"value2", @"key2", nil]; // Enough said
- No regex: You kind of get regex's in 3.2+, but they are very limited and require around 3-4 lines of setup to get anything done.
- Xcode: You are pretty much required to use Xcode and I don't like Xcode. Even if you use the "xcodebuild" CLI, you still have to create the project through Xcode.
- Closures: I guess we will be able to use these soon, but it is going to take awhile for all the API's to get updated to accommodate them.
- No dynamic variables: It's handy to be able to shove data into objects sometimes. It's a hack, but as long as you treat it as such you can save a lot of needless code. (You can do this via the ObjC runtime, but it's messy)
- Unit Testing: It barely exists and is difficult to use.
- No namespacing: ObjC handles namespaces by prefixing class names. Blah, that is so 1978.
- jeremymcanally 16y agoCompared to other C-supersets, it's not the worst thing ever, but yeah I totally agree with you that Obj-C is painful compared to many newer languages. So glad that MacRuby is pretty much usable now. I just wish I could use it for iPhone development. :)
- gte910h 16y agoOut of C, C++ and Objective-C, I'll take objective C any day.
- cpprocket 16y agoAm I the only person in the world who happened to like header files? It's a nice tool (for me) to separate interface declaration from modules/classes, so it's much easier to navigate massive codebases without the help from IDE. Seriously, how would you get a list of all functions in a module without an IDE? Besides, I put all my documentation into h-files as well, so other devs can pretty much see what I am doing without ever glancing at c-files. With Ruby or Java you need some advanced folding support in your editor or a full-fledged IDE.
- jawngee 16y agoNo I'm with you re: header files. These "people" don't also seem to get when you distribute a lib, you need to distribute headers with them.
- jawngee 16y ago> a vestigial language that isn't suited for a majority of application development. But good enough to write major parts of an operating system in by a company full of people easily smarter than you? Say what? > Header Files It's C for chrissakes. > No GC on the iPhone Because it's a performance penalty. Clock cycles on a phone are vastly more important than on a desktop/laptop. I can guarantee you this will change in a few years. > No NSDictionary/NSArray literals It's not a scripting language. Show me array literals in C or C++ that map to an underlying collection class that gives you fast enumeration and then we talk. > Xcode Personal preference. > Closures They're called Blocks. > No dymanic variables It's called 'id'. id whatever = [[YourObject alloc] init]; But even better: id whatever = [[NSClassFromString(@"YourClass") alloc] init]; Or how about setting properties on objects dynamically? [yourinstance setValue:@"Hello" forKey:@"property"]; Or dynamically dispatching methods? Ever messed with vtables in C++? > Unit Testing Agree, but that's changing. > No namespacing You bitch about all the typing, but you want to type out namespaces instead of using a prefix on your classnames. Ok ... Your confusing ObjC with Ruby, Python, et al. But it is not any of those. Like I mentioned elsewhere, it's a high level layer on a low level language. Adjust your expectations accordingly.
- cameldrv 16y agoArray literals: This one bugged me too. Try this: #define NSDICT(...) [NSDictionary dictionaryWithObjectsAndKeys: __VA_ARGS__, nil] #define NSARRAY(...) [NSArray arrayWithObjects: __VA_ARGS__, nil]