Apple's Swift developers discuss enhancements coming in Swift 4.1

Posted:
in General Discussion
Members of Apple's Swift Core team made a special appearance on the Swift Unwrapped podcast to discuss enhancements being rolled out as part of Swift 4.1 and how the company is expanding upon its efforts to engage with the community.





Apple's Doug Gregor, who works on the Swift compiler, and Ben Cohen, the release manager of the Swift Standard Library, joined the Swift Unwrapped discussion, focusing on improvements being made to generics and conditional conformances.

Apple's Swift 4.1 documentation explains that genrics enable developers "to write flexible, reusable functions and types that can work with any type, subject to requirements that you define. You can write code that avoids duplication and expresses its intent in a clear, abstracted manner."

The developers noted that Swift's Standard Library was originally designed from the start to take advantage of planned enhancements to generics, and now that Swift 4.1 is delivering a new "plateau" of support for generics, it is allowing them to "eliminate huge swathes of code" that is no longer necessary. Our goals for Swift are ambitious: we want to make programming simple things easy, and difficult things possible

The first beta of Swift 4.1 was released as part of the Xcode 9.3 and iOS 11.3 betas, and will ship when those releases are finalized, likely by the end of this month. Swift 4.1 is not binary compatible with 4.0, but is designed to be a source compatible update, meaning existing code should compile with the Swift 4.1 compiler.

Swift 4.1 also delivers improvements to the Swift Package Manager, Swift on Linux and brings "general quality improvements" to the compiler and Standard Library.

Apple first introduced Swift as a new programing language for Mac, iOS and other platforms in 2014. Since then it "has quickly become one of the fastest growing languages in history," the company notes on its Swift.org website.

"Swift makes it easy to write software that is incredibly fast and safe by design. Our goals for Swift are ambitious: we want to make programming simple things easy, and difficult things possible."

In November, freelancer site Upworks noted that Swift development was one of the fastest-growing skills in demand, with 200 percent year-over-year growth.

In January, an analysis of data from GitHub and Stack Overflow stated that Swift had tied Objective-C to enter the top ten development languages in terms of usage and discussion among developers. That's a remarkable feat given that Swift is largely focused on Apple's platforms, despite its open development and support for Linux.

Apple has been working hard to promote Swift has a language, promoting its "App Development with Swift" curriculum being used at over 70 high school and colleges worldwide, along with developing the free Swift Playgrounds app to make it easy and even fun to learn for everyone with an interest in development.

Comments

  • Reply 1 of 8
    Ok ... this is one thing I don’t like about Swift being open source. Progress is great, but it’s updated frequently enough that it’s a little bit of a pain without a lot of gain. Not everyone is a geek who feels they constantly need the latest and greatest in language developments. Swift is great and I really like the updates, but I don’t like having to alter code and wonder about deprecated or changed syntax as much as I’m having to.
    cornchipdewme
  • Reply 2 of 8
    Can swift replace C for tight memory environments?
    "Hello World" for example is much smaller in C.
    Looking forward to the new Swift standard lib with generics improvements.
  • Reply 3 of 8
    georgie01 said:
    Ok ... this is one thing I don’t like about Swift being open source. Progress is great, but it’s updated frequently enough that it’s a little bit of a pain without a lot of gain. Not everyone is a geek who feels they constantly need the latest and greatest in language developments. Swift is great and I really like the updates, but I don’t like having to alter code and wonder about deprecated or changed syntax as much as I’m having to.
    Such a nascent language was always bound to have these types of changes. In maturity languages find their stability. Considering how much Swift pioneered in joining so many different programming techniques into a cohesive, unified language, there was a lot of early learning that could only come through use. This is unrelated to the fact the language is open source - most of these changes, eg the Generics Manifesto and Constrained Conformances were driven by Apple themselves, not the open source community. And the additions from the community have tended to be additive, not changing things that break you. Those changes were driven by the Swift Core Team in pursuit of their goals for the language.
    dewmemattinozbloggerblognetmageStrangeDaysjony0
  • Reply 4 of 8
    ivanhivanh Posts: 372member
    “Apple has been working hard to promote Swift has a language, promoting its "App Development with Swift" curriculum being used at over 70 high school and collegesworldwide”
    The key word is “promote”, not support. How hard was it? There’s just a free of charge book everyone can download, and then self study it. You enrol in that course and pay a big sum of money, read the book, do exercises and a guided project, then do a project with Swift programming in chapters ahead. You finish the project and get a certificate, not endorsed by Apple, unlike those from Microsoft. After that, some small app developing firm may hire you, without giving you training. Short courses of it definitely not d”doing it at your own pace”, and it’s only good for those current practicing coding. 
    Is it another (potential/new) revenue stream of Apple? I don’t know. But you can always download the App Development with Swift from iBooks Store, free of charge.joined the course already, better get a refund now.

    A curriculum? Sorry, it’s just a e-book. You can get a much better quality of training from udemy at 1% of the course fees being charged by some of the 90 colleges.

    edited March 2018 jony0
  • Reply 5 of 8
    ivanhivanh Posts: 372member
    A curriculum? Sorry, it’s just a e-book. Don’t overstate it. 
    edited March 2018
  • Reply 6 of 8
    There's also a lot of Swift activity involving the Apple/IBM partnership, for example:

    Sorry, in advance for a series of large web page pics -- but they tell quite a story...




    https://developer.apple.com/ibm/

    If you follow the links to the IBM site and drill down you see things like this:



    https://www.ibm.com/cloud/apple-developer

    and this:



    https://console.bluemix.net/developer/appledevelopment/dashboard

    and this:


    https://console.bluemix.net/developer/appledevelopment/sdks-and-tools
    bloggerblog
  • Reply 7 of 8
    ctwisectwise Posts: 46member
    georgie01 said:
    Ok ... this is one thing I don’t like about Swift being open source. Progress is great, but it’s updated frequently enough that it’s a little bit of a pain without a lot of gain. Not everyone is a geek who feels they constantly need the latest and greatest in language developments. Swift is great and I really like the updates, but I don’t like having to alter code and wonder about deprecated or changed syntax as much as I’m having to.
    You're correct. They've been aiming for the binary compatible release for quite a while. I think everyone is hoping that when they hit that milestone the rate of serious change will die down. That said, conditional conformances are really, really cool.
  • Reply 8 of 8
    MarvinMarvin Posts: 14,228moderator
    georgie01 said:
    Ok ... this is one thing I don’t like about Swift being open source. Progress is great, but it’s updated frequently enough that it’s a little bit of a pain without a lot of gain. Not everyone is a geek who feels they constantly need the latest and greatest in language developments. Swift is great and I really like the updates, but I don’t like having to alter code and wonder about deprecated or changed syntax as much as I’m having to.
    They keep trying to add new features into the language to solve problems that crop up with their existing design but they are making it messier as they go. Optional chaining is an example:

    https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/OptionalChaining.html

    if let johnsStreet = john.residence?.address?.street {
        print("John's street name is \(johnsStreet).")
    } else {
        print("Unable to retrieve the address.")
    }

    This lets someone reviewing it see at a glance that the values can be nil but the reality is these values are going to be littered through hundreds of lines of code and somewhere, someone is going to get fed up keeping track of the question marks so they are going to force unwrap it and cause a runtime error.

    Given that you can't assume the developer is going to be careful enough to account for every nil value, the compiler could just raise a warning that a variable might be nil if it's assigning optionals and require that it is marked like:

    let johnsStreet = john.residence.address.street | nil;

    Then someone reviewing it can see that it can be a nil value and check if that has been accommodated without the clutter. The editor can just color in where it's potentially nil. This clutter is leading to people designing wrappers around Apple's internal APIs, which is a sure sign they are going about it the wrong way:

    https://github.com/SwiftyJSON/SwiftyJSON

    if let JSONObject = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]],
        let username = (JSONObject[0]["user"] as? [String: Any])?["name"] as? String {
            // There's our username
    }

    ^ That is an unreadable mess and other modern languages don't have this problem.

    That API reduces it to:

    let json = JSON(data: dataFromNetworking)
    if let userName = json[0]["user"]["name"].string {
      //Now you got your value
    }

    and it could even be:

    let json = JSON(data: dataFromNetworking)
    let userName = json[0]["user"]["name"] | nil

    Apple's software is one of the few examples where they don't follow their mantra of simplicity is the ultimate sophistication. Their language designers seem to forget that the people using their language aren't also language designers. They have to weigh best practises in theory against how the features are going to be used in the real-world and the different impact they have on efficiency and ease of use.
Sign In or Register to comment.