When Apple announced Swift, I heard a few people say “Hurray! Now I can be an iOS developer without learning Objective-C!” I have three messages for these people:
Before I proceed, let me preface this with a confession of love for Swift. The syntax is lovely. The Swift compiler will catch so many errors for us; I’m certain that when everyone is coding in Swift the reliability of apps will improve considerably. The enum construct is gorgeous. Swift is a major step forward for the entire iOS and Mac OS X ecosystem. But…
You can’t do everything in Swift. For example, if you want to use a library of C++ code in your application, you will need to talk to the C++ objects from Objective-C. Swift can call C functions, but I believe that if you are working with a lot of C functions and types, you will want to code in Objective-C.
The community talks in Objective-C. There are thousands of useful Objective-C snippets on StackOverflow and iOS dev blogs everywhere. Objective-C is the language we have used for the last six years to describe to each other how the Cocoa Touch libraries work. If you can’t read Objective-C, you won’t be able to understand this trove of knowledge.
The frameworks are written Objective-C. When you have a bug, it often doesn’t rear its ugly head until execution is deep in Apple’s code. If you want to understand what the debugger is telling you, you will need to understand Objective-C.
Objective-C is stable and well-tested. Swift looks great, but the language is evolving and the compiler is immature. If I were making a significant bet on developing an app this year, I would still use Objective-C.
C is a really simple little language, and Objective-C is a really simple little extension to C. Swift has many rules that Objective-C does not. (I, as an instructor, am already trying to figure out how I will explain the rules around optional variables and the proper use of ? and ! to signal the programmer’s intent around optionality.) These extra rules mean that the compiler can be much more pedantic about enforcing good coding practices, but it also means that the language will take longer to learn.
Objective-C requires programmers to be explicit. The Swift language lets the compiler do more work for the programmer. This is great—less typing for the programmer, right?—but it means that when you look at a line of code, it won’t mean much without a deep understanding of the context in which that line lives. Explicit languages are easier for beginners to understand.
Swift has a bunch of constructs that Objective-C doesn’t have. For example, generics make type checking better in Swift, but it makes that language considerably more complex.
To make Swift interoperable with Objective-C, Apple had to make Swift a lot like Objective-C. The difficult ideas that drive Objective-C like objects, strong and weak references, and inheritance are exactly the same in Swift—they are just expressed using a different syntax.
Honestly, it doesn’t matter which you learn first; eventually you will know both languages.