Teaching Swift - Apple’s new development language

This year, the WWDC was amazing. The shear amount of new stuff is overwhelming, and I still can’t believe that most of my wish list is now covered.

This year’s biggest surprise, however, which I was not really expecting (I guess nobody was), was Apple’s introduction of a new programming language—Swift. But now, Swift is here, and we have to deal with it.

Since its introduction, I have read many different reactions and comments about Swift. Some that come to mind are: ‘A new era has begun’, ‘Finally!!!’, ‘No more square brackets’, ‘It’s unreadable’, ‘Web developers can now develop iOS apps’, ‘It’s like a scripting language’, ‘Objective-C is easier to learn than Swift’, and ‘Swift is easier to learn than Objective-C’.

The truth is, Swift is a new programming language and now we have an alternative way to write iOS apps. Let me repeat this: Swift is a new programming language and now we have an alternative way to write iOS apps. There’s not much to add to this statement. And honestly, I don’t understand most of the comments that one can read on the Internet these days.

Since I teach iOS development, my first question was: From now on, what should I teach: Objective-C? Swift? Or both? Wrongly, I tried obtaining this answer from the Apple engineers at the WWDC. The majority of whom, didn’t know about Swift until Chris Lattner went on stage during the keynote. They were as astonished as the rest of us. The different answers I received, from the Apple engineers I net at WWDC, were driven by the fact that they were thinking from the point-of-view of Objective-C developers. In essence, the Apple engineers looked as though a new language had suddenly become their country’s official language, and they were speaking a language that had become suddenly banned.

Since the Apple engineers didn’t provide any useful answers, I instead asked myself. I thought deeply about my personal experience as an iOS developer and recalled my iOS teaching experiences over the past 6 years. I also spoke with my closest collogues and business partners. And the answer we decided on is: at iNVASIVECODE, we will teach Swift immediately and Swift will become our primary programming language. I love Objective-C, don’t get me wrong. I wish Objective-C could continue to evolve, but, I guess, Apple will now focus on Swift. The migration to Swift will happen as smoothly as past migrations, like Motorola to PowerPc, PowerPc to Intel, 32 to 64 bit, and so on.

When designers define a new programming language, they have different aspects in mind. Swift is based on a set of tools (LLVM, LLDB, CLANG and so on) that the same designers created in the past. Objective-C was adapted to them. Apple didn’t want to create a new programming language just to add a new programming language to the long list. Instead, Swift is the missing piece of the product chain, from the low-level hardware, to the high application level, and going through firmware, OS and APIs. If you think carefully, the programming language was the only piece not created by Apple. The lack of optimization at language level forced Apple to solve the problem at the ground.

Apple engineers know what they are doing, because they know, better than us, about the compiler, the debugger, the parser and so on. So, I am sure, Swift has been built with all the necessary details—many of which we cannot see—in mind. I really admire, and even slightly envy the fact that they introduced a completely new programming language. This is the first time, for many of us, to live in a moment like this one. Really exciting.

But now, let’s reconsider our iOS training classes, because we’re going to offer different solutions for different circumstances.

Companies that purchase our customized on-site training will be able to choose different options. Ultimately, our customer will decide the programming language they want to learn. Of course, we’ll show our trainees the seamless interoperability between Objective-C and Swift, but different factors will affect their decision.

For example, if a company has a highly productive iOS development team already in place, and this company already owns many products developed in Objective-C (Facebook, for example), the company will, most likely, ask us to keep teaching our advanced classes in Objective-C, so that their engineer’s productivity stays high. This same company may also ask us to provide them with a small introduction to Swift, which we can certainly do. Additionally, there will be cases of customers who still need to support iOS 6 (and sometimes even older than that—I know it seems crazy). Surely, there will also be cases where companies will ask us for an iOS training class completely in Swift. In the end, it’s more of a business decision, but, of course, we will help businesses make that decision.

Our public iOS training classes will use Swift as the primary programming language. This is because, our typical attendees are professional developers with experience in a programming language different than Objective-C. They usually come from Android development, and are trying to learn iOS, so that they can begin building real products as soon as possible. Their scope is not solely about learning a new programming language. For them, the programming language is just a tool for building iOS apps. If they could choose, of course, they would use the programming language they know best. But, since in most of the cases this is not possible (because they come from C++, Java, Ruby, C# and so on), they will need to learn a new programming language, and the difficulty of learning Objective-C or Swift is going to be mainly the same.

Think in terms of spoken languages. My mother tongue is Italian, but I learned to speak and write correctly in Spanish in roughly 3 months, because Spanish grammar and vocabulary are very similar to the Italian grammar and vocabulary. Additionally, I come from Puglia, a region in Italy where the dialects contain a lot of Spanish words. So, I learned Spanish swiftly, and I would say that learning Spanish is easy (for me). On the other hand, German was a very difficult language for me to learn. I lived in Austria 6 years, and after 3 or 4 years, I could still only use the language with limited working proficiency. That’s because German and Italian are very dissimilar in syntax, vocabulary, meaning, and pronunciations.

So, compared to Objective-C, is Swift easier or harder to learn? Well, actually, this is stupidest question I’ve heard over the past few days. Let me ask you this: what is harder to learn? Mandarin or Danish? German or Spanish? French or Russian? These comparisons make no sense. Each language has its own rules and exceptions. You can like them or not, but they are how they are. So, I don’t see the point of saying to the entire world “you need to know objective-c to learn Swift”. That’s pathetic, really.

Things evolve and change. Fighting the dinosaurs is hard. When Apple introduced the dot notation in Objective-C, I remember the same people saying: “Sacrilege!!! Evil!! Now, this is similar to Java.” And I still hear people saying: “I worked at NEXT. I created Cocoa”. Sure, this was in the 90s, a technological millennium ago, when a cellphone was as big as a handbag and LLVM, Xcode and iOS were non-existent. If we’re tied to the same piece of technology for too much time, we risk missing the point of innovation. That’s the main difference between these “grumpy” people and the Dev Tools team at Apple. A huge applause for them. I am so excited to learn something completely new. After 6 years of using the same technology and writing a tableview, a map, or a protocol in the same way a thousand times, I am glad I can do it a different way, with a different language, and learn new things.

I have taught iOS programming since 2008, and when people have come to learn Objective-C, I have seen every kind of reaction. Again, most of them are professional developers, so their most common reaction is to apply the syntax of the language they know best to Objective-C. For example, Java developers try to use the dot notation everywhere and they mainly don’t accept the usage of pointers. I get questions like, “Why can’t we do it in Objective-C? It is so obvious in Java.” But this question is no different then asking, “Why, in German, do you put the verb at the end of the sentence?” The answer, “It’s simply so. German grammar evolved in that way.”

Keep innovating,

Geppy

iOS Consulting | INVASIVECODE

iOS Training | INVASIVECODE

(Visited 131 times, 1 visits today)