Apple's new Swift programming language takes flight with Getty Images, American Airlines, LinkedIn,

Posted:
in Mac Software edited June 2015
Apple's new Swift programming language has only been available for a few months, but iOS and OS X developers from American Airlines, Getty Images, LinkedIn and Duolingo are reporting favorable impressions--ranging from increased productivity to fewer bugs in their shipping apps--as interest in the new language rapidly accelerates.

Swift at WWDC 2014


Swift, first introduced last June at Apple's Worldwide Developer Conference before shipping in September alongside iOS 8 and OS X Yosemite, tightly integrates with Chris Lattner's LLVM compiler. Swift intends to accelerate code writing, introduces modern programming concepts and aims to prevent common errors that can lead to app crashes.

Apple strategically invested in Swift

"We've been blown away by the reaction to Swift, our new programming language," Apple's chief executive Tim Cook stated last week. "Inventing a new programming language is something very few companies can do and we believe it will have a profound effect on our ecosystem.""Inventing a new programming language is something very few companies can do and we believe it will have a profound effect on our ecosystem" - Tim Cook

Creating a new programming language is an ambitious undertaking, but rapidly gaining adoption among developers is also steep challenge. In addition to the unique ability Apple has to promote and encourage adoption of Swift as the owner of the iOS and OS X platforms, Swift is also--by design--intended to be easy to incorporate into existing development projects alongside existing Objective-C code.

A primary factor attracting developer interest in Swift is that--compared to Objective-C--it's easier for new programmers to adopt and quickly become productive. That comes in part from elements it borrows from existing languages including Rust, Haskell, Ruby, Python, C# and CLU.

Apple's free iBook on Swift calls the new language "the first industrial-quality systems programming language that is as expressive and enjoyable as a scripting language."

The company is also emphasizing the new language's performance, noting that Swift code implementing a common search algorithm can execute 2.6 times faster than Objective-C, or up to 8.4 times faster than comparable code written in Python.

Developers flock to Swift

Cook also stated, "Swift became available in September as part of the Xcode tools and in the first month those tools were downloaded over 11 million times. A recent report from RedMonk showed that Swift has had unprecedented growth and is quickly climbing the list of the most popular programming languages.

"We've seen many of our developers choosing Swift as they build significant new projects and we are seeing fantastic work with Swift going on in education. Very recently, Stanford University released their Developing iOS 8 Apps with Swift course, which was posted to iTunes University, making this amazing resource available to everyone in the world."

Swift adoption Q1 2015


As reported by RedMonk in mid January, adoption of Apple's Swift has been "essentially unprecedented," entering the top 25 popular programming languages in just five months, a feat that Google's Go language took closer to five years to achieve. A variety of international universities and technical schools are already incorporating Swift into their courses

Boosting Swift's popularity going forward is the fact that a variety of international universities and technical schools are already incorporating Swift into their courses, from Germany's Technical University of Munich to Tecnol?gico de Monterrey in Mexico, Ing?sup in France, Aberystwyth University and Plymouth University in Great Britain and RMIT University in Australia.

In addition to Stanford University in Apple's backyard, a series of other American campuses are also teaching Swift including California Polytechnic Institute, Cuesta College in San Luis Obispo, University of California at Santa Cruz, Drexel University in Philadelphia, Full Sail University near Orlando, Northwest Kansas Technical College, the University of Missouri and Southern Methodist University in Dallas.

Getty Images' Swift adoption within Stream

Raphael Miller, Manager of Application Development at Getty Images, told AppleInsider he first got started with Swift at WWDC, participating in a two day hackathon. That resulted in Stream, a new app for iOS and OS X that lets users search, browse and share professional photography from the Getty Images portfolio.

Getty Images Stream app


Miller noted that while senior developers experienced in Objective-C could quickly get started with Swift, the new language is particularly accessible to junior developers, who typically have a year or two of experience in C# or are fresh out of a university teaching Java. Web developers familiar with Ruby also seem quick to pick up Swift, in contrast to the less conventional syntax of Objective-C.

For these newer developers, Swift makes learning the default programming language of Apple's platforms easier, allowing them to focus on picking up and understanding the Mac Cocoa or iOS Cocoa Touch APIs, Miller stated.

While he described Swift as being "pretty performant" as a language, the primary advantages he noted related to developer productivity. In contrast to the verbosity of Objective-C, the terseness of Swift lets you "do more with a lot less code" and complete "mundane stuff quicker." That makes it particularly attractive to Ruby developers, he noted, resulting in "iess writing and more building." Ruby is commonly used to rapidly prototype new concepts.

Swift's edge in developer productivity is particularly important in the consumer space, Miller noted, where developers seek to keep their apps fresh with new features and other tangible enhancements. With Swift, developers can "knock stuff out quickly," enabling innovative iteration while rapidly responding to user requests for new capabilities.

Swift also won't let you compile code with common errors, which "lets you know early on when you're doing something wrong," Miller said. Developers are "notified while you're typing code why this isn't going to work," sparing them the time wasted in compiling code with flaws.

Miller noted that while the initial Swift betas were "pretty raw," since then "each release has gotten better." While there are "still some crashes in Xcode" related to compiler issues and some problems with intermixing Objective-C and Swift, Miller said that the success of Stream--which is written entirely in Swift--has his team "ready to start the conversion of all our apps to Swift," with the full Getty Images app targeting a near term goal of reaching 50 to 60 percent Swift code.

Getty Images isn't doing any Android app development and Miller said it has no cross platform plans in the near future, so investing in Swift isn't constrained by portability issues. However, he also noted that Swift workshops run by his mobile team are gaining the attention of other developers in the company, including backend API coders using Microsoft's C# and web developers familiar with Ruby.

Swift has "people banging on our door," Miller said, particularly given the interest in mobile development in general. And unlike the less approachable syntax of Objective-C, the familiarity of Swift means that existing developers with an interest in expanding their skill set into mobile apps are "syntactically not scared of it."

Asked what he'd like to see from Apple related to Swift in the future, Miller said, "it would be nice to see more sample code" demonstrating, "here's a common problem, here's how you'd do it in Swift vs Objective-C," and outlining a cost benefit analysis of using Swift for different tasks

"Objective-C has been around so long, the best practices are out there," Miller stated. For Swift, there's less best practice architecture available, and ideally the best insight on how to use Swift most effectively would come from "from guys who designed it."

Swift takes off at American Airlines

AppleInsider also spoke with Phillip Easter, who manages American Airlines mobile app, and the company's iOS developer Matt Klosterman. Easter noted that American seeks to remain "progressive in the mobile space, looking for ways to improve our development cycle and for improvements to the platform," adding, "what Apple is doing with Swift is a great addition."

He noted Swift's tangible benefits include higher quality code that's easier to maintain along with related performance enhancements, and said American is "definitely adopting Swift going forward."

American Airlines app


However, as a native shop with a large existing code base, simply porting code from Objective-C to Swift is less attractive than being able to to build new features and enhancements in Swift. Apple has made it relatively easy to take such an incremental approach toward adopting Swift into existing projects.

Klosterman said he began investigating Swift immediately after WWDC, developing an "opportunistic approach to use it for new features" in the company's existing app. However, adopting Swift as a way to rapidly add new features isn't the only platform-related shift that developers at American needed to consider in the rollout of iOS 8.

iOS 8 also introduced support for Adaptive User Interfaces, which allow developers to flexibly adapt their apps to work on new device form factors--which Apple delivered just in time for the larger screens and higher resolutions of iPhone 6 and iPhone 6 Plus.

That feature enabled American Airlines to merge its separate iPhone and iPad apps to a common code base, making it easier to keep both apps in feature parity while significantly enhancing the ability to create and add new features. Adopting Swift to develop those new features dovetailed with support for Adaptive UI, accelerating development but also introducing new ways to think about how existing Objective-C code could be integrated with new Swift code.

Like Getty Images, American Airlines is also following an "incremental approach" in its adoption of Swift. Klosterman similarly noted iterative improvements to Swift since its debut at WWDC, noting that it "evolves with every release."

Asked what he'd like to see happen in the future, he noted that because Objective-C and Swift will "both be around for a while, it would be beneficial if interoperability improved with Swift," after noting that there are "interesting ways" that interoperability between the two could evolve.

At the same time, despite Swift appearing to be a freshly minted new language, Easter described it as having a "history and pedigree," having been in development for four years. "Apple has proven very thoughtful in what its doing," he stated.

LinkedIn adopts Swift for SlideShare

Apple's introduction of Swift last summer coincided with the conceptual prototyping of the new SlideShare app by LinkedIn, which hosts shared business presentations, infographics and videos similar to an Instagram for sharing presentations between business professionals.

LinkedIn SlideShare app


SlideShare's Engineering Manager Francisco Meza stated that the "timing worked perfectly for us to develop a brand new application completely in Swift (except for the little pieces of Objective-C required for interoperability), as we were just finishing the first early prototype of what would become the SlideShare iOS app."

Product Manager Andri Kristinsson added that the SlideShare team "was very excited to work with a brand new language right after it got announced ad WWDC and learn the ropes as we progressed building our app. We felt like we were working closely with the entire developer community during the team, our developers were active on forums and stack overflow-both learning and helping others learn," noting that "there were a couple of minor improvements we reported to Apple and those were added very shortly."

When asked about Swift's performance, Meza answered, "I must say that I am very satisfied by runtime performance of Swift based on the comparison of performance tracking metrics for similar pages of both SlideShare's app (Swift) and LinkedIn's flagship app (Objective-C)."

In terms of resulting code quality and stability, Kristinsson noted that "the crash rate of the SlideShare app is excellent and much better than in other apps our team has developed before."

Meza also addressed Swift's learning curve, stating that it "was not too steep. Swift is indeed a new language but it takes inspiration and borrows elements from other programing languages that have been around for a very long time: Ruby and Python among them. The high level of expertise in Ruby of the developers working on this project helped to flatten the learning curve of the adoption of Swift."

He added, "Given the great experience we have had with Swift so far, SlideShare will continue using it as its language of choice for iOS development."

Meza noted some issues experienced early on, including the lack of a private access modifier in the first few patch releases and initial issues with Xcode syntax highlighting, both of which he said have since been resolved.

"With the language itself," he added, "I believe the main issue we experienced was the fact that the language idioms were not yet established when we started using it, so part of our process of learning to work with Swift was coming up with our own conventions for best practices in the use of the language."

Meza added, "my main missing feature is support for exceptions, as in our experience, the writing of error handling could code could benefit with the use of this feature."

However, weighed against, as he described, "the benefits provided by using Swift--code that is more expressive, code that is easier to read and understand and code that is easier to maintain--I can confidently say that that decision of going with Swift instead of Objective-C was the right one for us."

Duolingo learns a new language

Another example of a new development project using Swift is Duolingo's Test Center, a companion app to the company's popular Duolingo foreign language learning app. Test Center is intended to certify a user's language proficiency in a monitored, time-limited exam.

Duolingo's Test Center app


A blog posting by the company titled "Real World Swift" described the original goals for Test Center, noting that it is "not a very performance-sensitive app," but that it was critical for it to be stable, as crashes would not only provide a "pretty bad user experience" for such an exam app, but also disrupt its design as a time-limited skill test.

Duolingo outlined detailed experiences with specific Swift features, but concluded that its Test Center app--developed "a bit over three months" by a single programmer--was able to achieve the intended goal of a "low number of crashes" in the hands of users as a popular download. Moreover, of the crashes the company tracked, four of the top five crash report triggers were related to code in an external Objective-C library, rather than its brand new Swift code.

The company attributed its app's stability in large part to "a solid software architecture and our adherence to sound engineering principles," but noted that "Swift eased the process of building this architecture and following best practices by eliminating entire classes of bugs by design. Correctly using Swift's type system, for example, caught and prevented numerous type errors at compile time during development, rather than ever surfacing in production."

Duolingo also identified some early adopter problems with Swift, noting "this newly minted language lacks some of the expressiveness found in other languages with modern type systems." The company also noted that its "biggest gripe-and source of frustration-with Swift is probably not the language itself, but the tooling around it."

It stated that "Xcode (Apple's Objective-C and Swift IDE) does not yet feel solid with Swift code. During development of our app, the IDE would often slow down noticeably or crash. There was no (or very slow) code completion most of the time, basically no debugger, unstable and unreliable syntax highlighting, a slow text editor (once the project reached a certain size), and no refactoring tools. Additionally, compiler errors are often incomprehensible and there are still quite a few compiler bugs and missing features (e.g. type inference sometimes goes awry)."

The company added, "while Xcode has gotten significantly better since we started, most of those points still hold true today, and somewhat spoil the experience. We're hoping that Apple shifts some of its focus to improving the developer tools."

The developers concluded, based on their initial experience with Test Center, that "Swift can be used to write stable, robust, and high-volume production apps. Our main app, Duolingo, already uses some Swift code, and we're planning on using it more and more in the future."

The company also recommended, "if you already have an app in Objective-C, you probably don't want to rewrite it from scratch just for the sake of using Swift, but you could consider adding new components in Swift."

As an example, the company described an app component that renders PDF assets, written in Swift. It was possible to use this Swift component in existing Objective-C code using a wrapper method. Conversely, the company stated that "it was easy to lift some of the existing Objective-C components of our main app and use them from Swift."

Swift plays a strategic role in Apple Watch, IBM iPad apps

Apple's pragmatic approach to making Swift interoperable with Objective-C appears to be working to enable iOS and Mac developers to incrementally adopt the new language, getting their feet wet without having to start over from scratch. Apple is also making extensive use of Swift itself, and is supporting new development in Swift for the upcoming Apple Watch.

IBM iPad apps


Swift is also credited with playing a significant role in Apple's recent partnership with IBM to develop a new class of "Mobile Ready" iPad apps for mobile business users. Last Summer, Cook stated, "we've forged a relationship with IBM to deliver a new class of mobile business solutions to enterprise customers around the world. We're working together to provide companies access to the power of big data analytics right on every employee's iPhone or iPad.

"Using Swift, we will collaborate to bring over 100 MobileFirst apps to enterprise clients, each addressing a specific industry need or opportunity. This is a radical step for enterprise. It opens a large market opportunity for Apple."
«13456789

Comments

  • Reply 1 of 171
    solipsismysolipsismy Posts: 5,099member
    1) Great article.

    2) Love Duolingo so I'm glad to learn about this new app. If you think Rosetta Stone is a great training method then step out of the 1990s with the far superior and completely free Duolingo.
  • Reply 2 of 171
    ``The company is also emphasizing the new language's performance, noting that Swift code implementing a common search algorithm can execute 2.6 times faster than Objective-C, or up to 8.4 times faster than comparable code written in Python.''

    The 2.6 times faster is an exaggeration, seeing as you would write the search in C and the ObjC class would be referenced in messaging only when you want the results.
  • Reply 3 of 171
    asdasdasdasd Posts: 5,330member
    A bit off of a puff piece. There's a "iOS developers unhappy with swift" article waiting to be written by someone who can research.
  • Reply 4 of 171
    poksipoksi Posts: 481member
    Due to its level of expressiveness, type inference, sugar syntax and other "typing shortcuts" Swift is hard to read and therefore hard for code reviews. It's quite obvious the language is optimised for small devices and tailored to indie developers.

    Mobile is becoming enterprise, too. So Swift will have to evolve in this direction as well.
  • Reply 5 of 171
    asdasd wrote: »
    A bit off of a puff piece. There's a "iOS developers unhappy with swift" article waiting to be written by someone who can research.
    It's by DED, so it's going to be a puff piece. Though I will give him credit. I enjoyed reading this article and he avoided his usual tirades.
  • Reply 6 of 171
    rogifanrogifan Posts: 10,669member
    Was the photos app developed using any Swift?
  • Reply 7 of 171
    asdasdasdasd Posts: 5,330member
    rogifan wrote: »
    Was the photos app developed using any Swift?

    I don't see any indication that it was. Disassembling indicates use of an UXKit but nothing swift related.
  • Reply 8 of 171
    wizard69wizard69 Posts: 12,912member
    It's by DED, so it's going to be a puff piece. Though I will give him credit. I enjoyed reading this article and he avoided his usual tirades.

    Of course it was a puff piece, that should surprise no one. Like you I was at least able to read all the way through the article which is actually a surprise for DED.
  • Reply 9 of 171
    Swift is a nice language and certainly a few steps up from Java and Objective C, but there are better languages out there.

    Where I find Swift wanting is in support for union types (many of the newer languages have them or are adding them), not completely eliminating the possibility of the equivalent of a NullPointerException with its built-in Optional, as well as (last I looked) eliminating exceptions completely. Swift seems to take Perl-ish shortcuts at times where more explicitness would be better for readability. The let/var variable declarations treat mutability and immutability as equivalent, whereas immutability should be encouraged. From the Swift guide, I can't tell if generics are invariant or support covariance/contravariance, whether generics are reified or erased, or whether they support declaration site or use site (or any) variance.

    So once any performance issues are ironed out, iOS developers will have a better language to work with than Android's Java, but not as good as Ceylon (http://ceylon-lang.org).
  • Reply 10 of 171
    rogifanrogifan Posts: 10,669member
    asdasd wrote: »
    I don't see any indication that it was. Disassembling indicates use of an UXKit but nothing swift related.

    So I wonder then if Apple is developing anything using Swift.
  • Reply 11 of 171
    Quote:

    Originally Posted by wizard69 View Post





    Of course it was a puff piece, that should surprise no one. Like you I was at least able to read all the way through the article which is actually a surprise for DED.



    I get tired of reading such criticisms and put-downs of Daniel's writings. If you don't like what he writes, don't read it.

     

    My take is folks like you call articles such as this one "puff pieces" because they stand in contrast to the mostly idiotic criticisms and hit pieces published by people at CNET and the like. 

     

    I say if you want to offer Daniel constructive criticism, contact him privately, instead of throwing things out for everyone to see. 

  • Reply 12 of 171
    emig647emig647 Posts: 2,416member
    Quote:
    Originally Posted by JavaCowboy View Post



    Swift is a nice language and certainly a few steps up from Java and Objective C, but there are better languages out there.



    Where I find Swift wanting is in support for union types (many of the newer languages have them or are adding them), not completely eliminating the possibility of the equivalent of a NullPointerException with its built-in Optional, as well as (last I looked) eliminating exceptions completely.

     

    It has been a long underlined point by Apple that exceptions are to be avoided at all costs in Objective-C and Cocoa. Exceptions simply marked an unrecoverable state, a last chance effort to grab information before the app was killed. There are inherit (no pun intended) issues surrounding memory and inheritance and exceptions. The NSError pattern has always been the preferred way to handle these situations. A lot of Java and C++ developers glossed over this. 

     

    NSException wasn't added until later in Cocoa's Foundation after Apple adopted it. It became a religious war between devs, so this time around, Apple just did away with exceptions entirely.

  • Reply 13 of 171
    knowitallknowitall Posts: 1,463member

    I have not much Swift experience yet, but so far it looks very good.

    Swift is everything C++ promises but can't deliver because of its extensive syntax, non sparse notation and debug Hell. Generics (essentially writing type independent code) operator overloading, objects and inheritance are all expressed in a sparse way and can be used with ease.

    Another important feature is that functional programming (essentially, programming side effect free) is included and functions and closures (nameless functions) are 'first class citizens'. This is a big one, because code written in a functional way can be easier to prove correct and that's essential for some important applications (and will be much more important in the future).

    Pattern matching seems to be a little weak, but I might not have seen everything yet.

     

    Apples playground is an excellent idea and seems to work fine (a few crashes for such a new piece of code can be forgiven) and seems to be inspired by Mathematica (from Wolfram) that had such an interactive programming environment on the NeXT, way back in 1990 (this is still the benchmark for such an environment, it worked flawless and fast on a 25Mhz 68040 ...)

     

    All in all an excellent achievement of Apples language team, kudos!

     

    By the way, thanks Daniel (and AppleInsider) for this information.

  • Reply 14 of 171
    knowitallknowitall Posts: 1,463member
    Quote:

    Originally Posted by emig647 View Post

     

     

    It has been a long underlined point by Apple that exceptions are to be avoided at all costs in Objective-C and Cocoa. Exceptions simply marked an unrecoverable state, a last chance effort to grab information before the app was killed. There are inherit (no pun intended) issues surrounding memory and inheritance and exceptions. The NSError pattern has always been the preferred way to handle these situations. A lot of Java and C++ developers glossed over this. 

     

    NSException wasn't added until later in Objective-C after Apple adopted it. It became a religious war between devs, so this time around, Apple just did away with exceptions entirely.




    The idea behind exceptions seems excellent, but in practice it is hardly used and makes code difficult to read and comprehend (cause and effect isn't located near each other in the code and you still have to handle the exception in a sensible way and that can be difficult).

    So I understand the language developers (at Apple) left it out to reduce language complexity.

  • Reply 15 of 171
    asdasdasdasd Posts: 5,330member

    I get tired of reading such criticisms and put-downs of Daniel's writings. If you don't like what he writes, don't read it.

    My take is folks like you call articles such as this one "puff pieces" because they stand in contrast to the mostly idiotic criticisms and hit pieces published by people at CNET and the like. 

    I say if you want to offer Daniel constructive criticism, contact him privately, instead of throwing things out for everyone to see. 

    Utter bull. He's publishing on the Internet. There's a forum to discuss his writings. We discuss it.
  • Reply 16 of 171
    MacProMacPro Posts: 18,470member

    I get tired of reading such criticisms and put-downs of Daniel's writings. If you don't like what he writes, don't read it.

    My take is folks like you call articles such as this one "puff pieces" because they stand in contrast to the mostly idiotic criticisms and hit pieces published by people at CNET and the like. 

    I say if you want to offer Daniel constructive criticism, contact him privately, instead of throwing things out for everyone to see. 

    I couldn't agree more. Just speaking personally, DED's editorials are what makes me keep reading AI more than anything else on AI. I must say after 35 years + personal history with Apple I find is take on that history the most accurate of any journalist I have ever read. As to new fields, I cannot judge but I certainly appreciate his hard work in bringing such a vast amount of information to these pages on a regular basis in his editorials. They elevate AI above being just a rumor / bitching site. AI would be so much the poorer with out them.

    Perhaps these regular critics might like to submit a few editorials to AI? If they have a genuinely interesting viewpoint I would like to read it fully, not as snippets as they relate to DED's work. I am not saying this in a snarky way, I mean it seriously. Many of the folks here on AI are very smart and well versed in their own fields.
  • Reply 17 of 171
    MacProMacPro Posts: 18,470member
    asdasd wrote: »
    Utter bull. He's publishing on the Internet. There's a forum to discuss his writings. We discuss it.

    No one is worried about 'discussing' . The poster was commenting on the tiresome bashing for its own sake which is rarely constructive. Staring a 'discussion' with "Utter Bull" isn't constructive nor conducive to further discussion either, IMHO.
  • Reply 18 of 171

    Thanks, DED, for the article on Swift.

     

    This excerpt from Apple's "The Swift Programming Language" ebook has gotten me interested in learning this language:

     

    “Swift is friendly to new programmers. It is the first industrial-quality systems programming language that is as expressive and enjoyable as a scripting language. It supports playgrounds, an innovative feature that allows programmers to experiment with Swift code and see the results immediately, without the overhead of building and running an app.

    Swift combines the best in modern language thinking with wisdom from the wider Apple engineering culture. The compiler is optimized for performance, and the language is optimized for development, without compromising on either. It’s designed to scale from “hello, world” to an entire operating system. All this makes Swift a sound future investment for developers and for Apple.

    Swift is a fantastic way to write iOS and OS X apps, and will continue to evolve with new features and capabilities. Our goals for Swift are ambitious. We can’t wait to see what you create with it.”

    Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l

     

    This information is far more credible to me than the incessant quips from all the chronic curmudgeons on these article threads.

  • Reply 19 of 171
    asdasdasdasd Posts: 5,330member
    No one is worried about 'discussing' . The poster was commenting on the tiresome bashing for its own sake which is rarely constructive. Staring a 'discussion' with "Utter Bull" isn't constructive nor conducive to further discussion either, IMHO.

    I didn't start a discussion with utter bull. I answered somebody who think that we should disagree with DED in PM only.

    DED knows little or nothing about swift, it's uptake or the feelings towards it.
  • Reply 20 of 171
    javacowboy wrote: »
    ... The let/var variable declarations treat mutability and immutability as equivalent, whereas immutability should be encouraged.

    What are you saying here? Let is immutable and var immutable and Apple strongly encourage 'let' unless mutability is required.

    Did I miss something?


    And I wish writers would drop that utterly pointless phrase "going forward".
Sign In or Register to comment.