7 ms·
Yup, ObjC is light and scripty. Whenever you don't like what it's doing you just make it do what you want, categories, cast to id, swizzling, respondsTo, NSSele
by fleitz 11y ago
Yup, ObjC is light and scripty. Whenever you don't like what it's doing you just make it do what you want, categories, cast to id, swizzling, respondsTo, NSSelectorFromString, etc, and when it's too slow you write those functions in C/C++ which it integrates well with.
Swift you're always contorting yourself to express things in a way that the language wants, it reminds me of writing java, it worships far to heavily at the altar of type safety as if type safety was a goal in and of itself.
ObjC is practical, Swift is academic.
- laveur 11y agoI couldn't agree more! There is a ton of things that you can do with the run time that just doesn't seem possible in swift.
- cmollis 11y agoagreed
- morqon 11y agoHappily, the two co-exist well, and increasingly so. Where one is a better choice for a particular job, you have it. It's just that you now have two tools to choose from.
- _3u10 11y agoNo they don't. If you use swift features then your class is inaccessible to ObjC. If you mark your class @objc then you can't use many swift features. The only thing that works well is writing most of your app in swift and writing ObjC wrappers for C/C++ code, because dealing with C in Swift is atrocious and many libraries simply don't work in Swift because of initialization issues with complex structs. Also, having two tools to choose from that do practically the same thing is never really a good idea because you waste time trying to figure out whether Swift->ObjC interop is going to fuck you over more than ObjC->Swift interop for this particular class. Also, once you start mixing code and have your code importing a Swift header and your Swift bridging header importing your ObjC classes you start getting huge compile times as anytime you change an ObjC header your entire swift code has to be recompiled which takes forever because the swift compiler is dog slow. My advice, pick one language for your project and stick with it, the language I would advise until Apple writes base libraries in Swift is ObjC, because if you run into performance issues C/C++ is going to save your ass far more than Swift will. And mostly because var cell = tableView.dequeResuableCell("foo") as! CustomTableViewCell is MORE typing than CustomTableViewCell *cell = [tableView dequeResuableCell:@"foo"];
- tempodox 11y agoAnd what the heck does that exclamation mark even do? Will the program then crash on NULL (more unsafe than ObjC) or will it just liquify to Kentucky Bourbon? Personally, I find the concept of NULL (though toxic) more comprehensible and manageable than all those question & exclamation marks in Swift.
- _3u10 11y agoYup, [nil anyMessageReturnsNil] is probably the best decision ever made in ObjC.
- Alphasite_ 11y agoThat seems the opposite, very few things need those dynamic features and those that do can be special cased, which makes Objc the more pure but equally more academic language to me.
- jonsterling 11y agoI assume by "academic" the other poster meant "informed by academic research". Swift is evidently more so than Objective-C.
- fleitz 11y agoBy academic, I meant academic problems that Swift solves such as increased type safety... Not academic research as in we did a study of developers who write iOS apps and determined that type safety as implemented in swift helps great developers write apps faster. (F# on the other than has a great type system that doesn't get in your way)
- tragic 11y agoIt's all academic until things blow up at runtime. Choosing more type safety over less is a pragmatic concern - one input among many into the cost benefit analysis we all do when picking languages and platforms. More type-safe languages tend to have more boilerplate and hoops to jump through, but they also tend to be more robust. The latter can be proven theoretically more efficiently than with empirical research, but it is no less true for it. We are limited by the laws of mathematics, however 'pragmatic' we fancy ourselves. Having never written a line of swift or ObjC, I have no opinion on the matter at hand. I also make my money out of the thoroughly unsafe Javascript. But it's not a good idea to blithely dismiss type safety as an ivory tower concern of academic CS. The benefits are real, and can be measured in the number of panicked pages/emails received at 3am.
- fleitz 11y agoHave you thought about switching to type script to get the benefits of type safety? http://www.typescriptlang.org/ http://www.typescriptlang.org/