[英]《Swift基礎教程》作者Boisy Pitre:Objective-C很不錯,但它已經是過去時(圖靈訪談)

盼盼姐發表於2015-09-23

Boisy G. Pitre是一位資深蘋果開發專家,曾任Siri語音識別技術提供方Nuance公司Mac產品小組的資深軟體工程師,參與開發了語音識別軟體Dragon Dictate。MacTech雜誌“Developer to Developer”月度專欄作家,曾多次在MacTech和CocoaConf等會議上發表技術演講。現任情緒識別公司Affectiva的移動遠景規劃師,領導團隊致力於將公司的表情分析技術遷移到移動平臺。Boisy著有《Swift基礎教程》一書。

[英]《Swift基礎教程》作者Boisy Pitre:Objective-C很不錯,但它已經是過去時(圖靈訪談)

iTuring: What was your purpose of writing Swift for Beginners?

When Apple introduced Swift, I knew it would become an important part of the computer language landscape in the years ahead. It was my goal to bring readers a fun and easy introduction into this new language so that they could get a head start, and get up to speed quickly. It was challenging because there is so much in the language to discuss, and I didn’t want to overwhelm the reader with too much. It was written with the beginner in mind, and I think it has been well received in that regard.

iTuring: Would you please introduce to your readers about your work at Affectiva?

Certainly. Affectiva is a technology company which brings emotional intelligence to digital experiences. Their technology is based on real-time facial analysis to determine the emotional state of an individual. I am their Mobile Visionary, where my responsibility is to bridge the technology to the mobile world. We’ve achieved that and now I work to improve the technology on mobile platforms such as iOS an Android. We have an SDK that developers can use to integrate emotional intelligence into their apps.

iTuring: In your opinion, what will open source of Swift change about its ecosystem and dynamics between iOS and Android?

It is difficult to predict how Swift as an open-source language will impact Android development. Google has their own language initiative with Go, which is what Swift is to iOS. I would expect that there will be work towards writing Android apps in Swift, just as there is writing iOS apps in Go. Will one be more successful over the other? Or will the respective languages cling to their own natural platforms? Only time will tell. However, Apple’s decision to open source the Swift language certainly has changed the dynamics for the better.

iTuring: What does Swift integrate from other languages? What are the favorite features you like about Swift?

All computer languages tend to borrow from other languages. For Swift, it’s no different. I see a good deal of the Rust language in Swift from a syntax and memory model point of view. It’s apparent that Swift’s emphasis on safety keeps it at arm’s length from C and C++, so there is very little in common there. I believe Apple has tried hard to make Swift its own language on its own terms. We’ll see how that plays out.

My favorite feature of Swift by far is its clarity in syntax. Establishing a constant variable with the ‘let’ keyword vs. a mutable variable with the ‘var’ keyword simplifies the syntax quite a bit from the C/C++ way. Functions are clearly written with enforced named parameters (like Objective-C), and closures are easy to create and use.

iTuring: Is it possible that Swift will take place of Objective-C completely in the future?

Sure. How long that will take is anyone’s guess, but it could happen in 5 years or even less. It’s easy to forget that computer languages have long, long lives (C is four decades old at this point). Objective-C won’t completely go away, but I can see a time where it is relegated to a very small portion of the languages pool.

iTuring: Objective-C still constitutes much of iOS's frameworks, which are invoked by bridging header file nowadays, will there be simpler method of invocation in the future? Will there be more frameworks based on Swift from now on?

That is almost certain to happen, and I believe Apple is working hard right now to do just that. Keep in mind that it is a huge task, as there are dozens and dozens of frameworks that need to be converted. I believe this work will be completed before too long, and we’ll soon see a time where new frameworks are Swift only and do not even have an Objective-C counterpart. When this happens, it will certainly have an impact on the use of Objective-C going forward.

iTuring: What do you recommend a beginner to learn first, Objective-C or Swift?

Definitely Swift. Objective-C is a great language, but it carries the legacy (and baggage) of C. It’s also going to become less and less relevant as time goes on for writing apps. In fact, I would not even start a new iOS or OS X project in Objective-C. I would only use Swift going forward for new projects.

iTuring: For programmers who have already had a good understanding of one or two programming languages, what would you recommend them to do in order to learn a new language in an effective and efficient way?

It depends on what those one or two languages are. If those two languages are Objective-C and Swift, or C and C++, or any combination thereof, I would recommend learning an entirely different language to challenge the mind. Imperative languages like C, C++, Objective-C, and Swift tend to follow the same models, so it’s easy to learn a new language of that class. It’s important to expose yourself to different language paradigms, so I would recommend learning a functional language like Scheme. Even though it’s not a language you will write apps in, it will expand your understanding of computer languages in general.

iTuring: In the process of learning programming languages, when is the best time to engage with masses of libraries and APIs? Is it necessary for a programmer to know every API he/she might use?

I often use the analogy of the carpenter with a tool belt. Does he have every conceivable tool in his belt? No… only the ones he uses most often. When he has to get a specialized tool, he will walk to his truck, open the large toolbox there, and use that tool once or twice, then put it up. It’s the same with programming languages and APIs. It is impossible to know every API completely, but the more you know, the better you can solve a problem. I would suggest learning the language to a great degree at first, and then continue to study the nuances of the language while introducing yourself to the frameworks and APIs that you can use to create useful apps in that language. Then, once a week, pick a new API and commit 3-5 hours of study to learn about what it does. You may not use that API very much, but you will know it exists, and when the time comes, you can be prepared to recommend it to solve a particular task.

iTuring: For an expert of iOS development, what does his/her knowledge framework looks like?

A well rounded iOS expert has a mastery of four things:

  • (1) the language used to write apps (Swift / Objective-C),
  • (2) a command of the tools to create the software (Xcode),
  • (3) strong knowledge of the basic frameworks and APIs that go into writing iOS apps, and
  • (4) an eye for good UI design.

It takes many apps and hundreds of hours of programming to approach this level. Each app brings its own requirements and APIs that it needs, so the more apps you write, the more exposure you get to the breadth of Apple’s frameworks and the better your UI design skills become.


更多精彩,加入圖靈訪談微信!

相關文章