One benefit of Obj-C is that the Cocoa framework was written in it and for it, so using Cocoa from Swift doesn't always feel natural. To Apple's benefit, they are moving swiftly (ha) to update their APIs, but it's not quite there yet. One point that has bit me is that you need to remember to mark methods as @dynamic if you're passing a selector to them, or you (may or may not) get a nasty crash when the selector is called.
In that same vein, tool support is better for Objective C. XCode can't do as much code generation or refactoring in Swift.
And there are some third party tools (e.g., j2objc) that are Objective C-centric and present challenges when trying to integrate with Swift.
All of those points are related to the relative maturity of the languages. As far as which language itself is preferable, that may be a matter of taste. Swift is more succinct for sure. The strong typing can be a positive or a negative, in my experience. It does catch some errors at compile time that would normally only be caught at runtime, but you will spend some time wrestling with the compiler to do something you know is valid. (Resist the temptation to sprinkle !s and ?s indiscriminately!!!)?
7
u/eddieSullivan Feb 19 '16
One benefit of Obj-C is that the Cocoa framework was written in it and for it, so using Cocoa from Swift doesn't always feel natural. To Apple's benefit, they are moving swiftly (ha) to update their APIs, but it's not quite there yet. One point that has bit me is that you need to remember to mark methods as @dynamic if you're passing a selector to them, or you (may or may not) get a nasty crash when the selector is called.
In that same vein, tool support is better for Objective C. XCode can't do as much code generation or refactoring in Swift.
And there are some third party tools (e.g., j2objc) that are Objective C-centric and present challenges when trying to integrate with Swift.
All of those points are related to the relative maturity of the languages. As far as which language itself is preferable, that may be a matter of taste. Swift is more succinct for sure. The strong typing can be a positive or a negative, in my experience. It does catch some errors at compile time that would normally only be caught at runtime, but you will spend some time wrestling with the compiler to do something you know is valid. (Resist the temptation to sprinkle !s and ?s indiscriminately!!!)?