Preface
On December 8, 2013, US President Barack Obama “asked every American to give it a shot to learn to code” (watch it here), kicking off the Hour of Code campaign for Computer Science Education Week 2013. “Learning these skills isn’t just important for your future, it’s important for our country’s future,” President Obama said.
In February 2013, Mark Zuckerberg and Bill Gates and several other big names in IT “want kids to learn code” (video). I particularly like the quote at the beginning of the video:
You don’t have to be an American to get the message: coding (aka. programming) is an important skill for this information age. Besides the importance of programming, the other message those VIPs also tried to convey is that “you can do it”.
Learning programming is a way to master communication with computers, by giving them instructions to perform tasks for you. A programming language is a language that is used to write instructions for computers to understand and execute. There are several popular programming languages such as Java, C#, Ruby, and PHP. For beginners, don’t fixate on one. Computers internally work the same way, mastering thinking in programming is more important than an individual language. In my opinion, different programming languages are like dialects. I learned and taught myself over a dozen of programming languages. Once you have mastered one, it is easy to learn another.
In this book, I will use Swift, a new programming language from Mac OS X and iOS. Swift was first unveiled at the Apple Worldwide Developers Conference (WWDC) 2014, Apple describes Swift as “a successor to both the C and Objective-C languages” on its website. Before Swift, Objective-C was the only programming language you could use to build Mac and iOS apps. Redmonk programming language rankings for 2015 shows a huge growth in popularity for Apple’s new Swift development language. According to the results, Swift went from the 68th most popular language last quarter (when it launched) to the 22nd, a jump of 46 spots which is “unprecedented in the history of these rankings.”
In June 8, 2015 at WWDC 2015, Apple announced that the company is open-sourcing the Swift 2.0. “We think Swift is the next big programming language, the one that we’ll all be doing application and system programming on for 20 years to come,” Craig Federighi, Apple’s senior vice president of software engineering, said. “We think Swift should be everywhere and used by everyone.”
What do these mean? Swift will be the main programming (replacing Objective-C) for coding applications for Apple’s iOS, Mac OS and tvOS platforms, and developers like it. A good news for beginners, comparing to Objective-C, Swift is a lot easier to learn. So learn and master Swift, as President Obama said in the video, “Don’t just download the latest app, help design it; Don’t just play on your phone, program it”.
What is unique about this book?
A typical how-to-program book will go through the programming concepts, syntax and followed by demonstrations with simple examples. I have read dozens of them (for different programming languages or tools) before and have taught this way at universities. It was not an effective approach. It is more like a teacher dumping knowledge upon students. But I did not know a better way, until I discovered The Michel Thomas Method.
The Michel Thomas Method was developed by Michel Thomas for teaching foreign languages. Thomas claimed that his students could “achieve in three days what is not achieved in two to three years at any college”. My understanding of this method is that the teacher starts with a simple conversation scenario, then gradually expands the scenario with a few new words each time. That way, students are familiar with the conversation topic and the majority of words or sentences, while learning some new, in real interesting conversations.
I believe this teaching method can be applied to programming. Not only a programming language may also be considered as ‘a language’, but also very practical. The ‘conversation’ in speaking languages are exercises in programming. People learn better when they get satisfaction or feedbacks and see their programs works..
As I said before, thinking in programming is much more important than being familiar with a programming language. There is no better way than writing real programs for real exercises. In this book, I have chosen the exercises that are very simple to understand, besides teaching values, they are useful and fun to do.
There are also some programming quiz books. I often find some of those exercises are long and hard to understand. Quite commonly, the authors seem to be fond of showing off their programming skills or smart solutions. It won’t be the case in this book. This book is a guide to programming and its purpose is to teach. After you finish all the exercises, you will be able to write working (might not be perfect) programs, and with confidence to continue to learn and grow.
Who should read this book
Every one who wants to write apps (and games) for Mac OS X, iOS, watchOS and tvOS. In particular, I would strongly encourage young people to give it a go.
How to read this book
It is highly recommended to read this book from page to page. The exercises are organized into chapters, exercises within each chapter generally follows an ‘easy-to-hard’ pattern.
The solutions for all exercises are listed in Appendix 2, and also can be downloaded on the book website, for access code see the Resources section of this book.
Send me feedback
We’d appreciate your comments, suggestions, reports on errors in the book and code. You may submit your feedback on the book site.
Zhimin Zhan
Brisbane, Australia