Preface
In July of 2010, Chris Lattner created a folder on his computer called Shiny, and a new computer language was born. Four years later, in 2014, that language, renamed Swift, was introduced to the public, and was greeted with a mixture of surprise and excitement — and skepticism.
Prior to that moment, Cocoa programming, on iOS and before that on Mac OS, had always been done chiefly in Objective-C. The Cocoa frameworks that give an iOS app its functionality are based on Objective-C; they expect to be spoken to in Objective-C. The tradition of using Objective-C was long and deeply ingrained. For all its faults, Objective-C was the language we had learned to live with as the price of programming Cocoa. Could Cocoa be spoken to in a whole new language? Could this new language replace Objective-C as the iOS developer’s language of choice?
No one knew. I certainly didn’t know! So the first thing I did, as an experiment, was to try translating my own existing iOS apps into Swift. Not only was I able to do it, but I found the new Swift versions easier to understand and maintain than their Objective-C originals. From that moment, I was convinced that the vast majority of new iOS programmers would hitherto adopt Swift. I was right.
Swift is a superb language to learn, even (perhaps especially) if you’ve never programmed before, and is the easiest and clearest way to program iOS. It has these salient features:
- Object-orientation
-
Swift is a modern, object-oriented language. It is ...