Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's up with Swift 5?

Bas Broek
September 23, 2017

What's up with Swift 5?

This talk was presented at FrenchKit 2017.

Bas Broek

September 23, 2017
Tweet

More Decks by Bas Broek

Other Decks in Programming

Transcript

  1. WHAT'S UP WITH
    SWIFT 5?
    BAS BROEK
    1 — @basthomas

    View Slide

  2. IOS @ XING
    MOYA
    SWIFT WEEKLY BRIEF
    2 — @basthomas

    View Slide

  3. ABI STABILITY
    3 — @basthomas

    View Slide

  4. !
    4 — @basthomas

    View Slide

  5. ... STOP ME IF YOU THINK
    YOU'VE HEARD THIS ONE
    BEFORE
    5 — @basthomas

    View Slide

  6. SWIFT 5'S
    PRIMARY FOCUS
    IS ABI STABILITY
    6 — @basthomas

    View Slide

  7. This would remove the need for
    apps to distribute their own copy
    [of the Swift libraries].
    7 — @basthomas

    View Slide

  8. !
    8 — @basthomas

    View Slide

  9. REQUIREMENTS
    > Generics features in the standard library
    > API resilience
    > Memory ownership model
    9 — @basthomas

    View Slide

  10. REQUIREMENTS
    > Generics features in the standard library
    > API resilience
    > Memory ownership model
    10 — @basthomas

    View Slide

  11. GENERICS FEATURES IN THE STANDARD
    LIBRARY
    > SE-0143: Conditional conformances
    > SE-0157: Recursive constraints on associated types
    11 — @basthomas

    View Slide

  12. CONDITIONAL CONFORMANCES
    // Swift 4
    extension Array: Equatable where Element: Equatable {
    // ERROR: Extension of type 'Array' with constraints
    // cannot have an inheritance clause
    }
    // Swift 5
    extension Array: Equatable where Element: Equatable {
    var hashValue: Int {
    ...
    }
    }
    12 — @basthomas

    View Slide

  13. RECURSIVE CONSTRAINTS ON ASSOCIATED
    TYPES
    // Will not compile in Swift 4, will in Swift 5
    protocol Sequence {
    associatedtype SubSequence: Sequence
    where Iterator.Element == SubSequence.Iterator.Element, SubSequence.SubSequence == SubSequence
    // Returns a subsequence containing all but the first 'n' items
    // in the original sequence.
    func dropFirst(_ n: Int) -> Self.SubSequence
    // ...
    }
    13 — @basthomas

    View Slide

  14. REQUIREMENTS
    > Generics features in the standard library
    > API resilience
    > Memory ownership model
    14 — @basthomas

    View Slide

  15. MEMORY OWNERSHIP MODEL
    > Partly implemented in Swift 4 (SE-0176: Enforce
    Exclusive Access to Memory)
    > Swift 5 takes on "only" everything that is needed for ABI
    stability
    15 — @basthomas

    View Slide

  16. MEMORY OWNERSHIP MODEL
    > The Law of Exclusivity
    > The standard library must adopt ownership annotations
    on parameters
    16 — @basthomas

    View Slide

  17. SOURCE STABILITY
    > Source compatibility mode
    > Supports Swift 4, maybe Swift 3
    17 — @basthomas

    View Slide

  18. SOURCE STABILITY GUIDELINES
    The current implementation must:
    > actively cause problems for users
    > be clearly better and must not conflict with existing
    Swift syntax
    > have a reasonably automated migration path for
    existing code
    18 — @basthomas

    View Slide

  19. SWIFT EVOLUTION
    19 — @basthomas

    View Slide

  20. PROPOSALS
    > String ergonomics
    > Improvements to existing standard library facilities
    > Foundation improvements
    > Syntactic additions
    > Laying the groundwork for a new concurrency model
    > ... and more?
    20 — @basthomas

    View Slide

  21. EVOLUTION PROCESS
    > Proposals need a working implementation
    > ... including test cases
    21 — @basthomas

    View Slide

  22. !
    22 — @basthomas

    View Slide

  23. HOW DO I KEEP UP WITH ALL OF THIS?
    > Swift Weekly Brief
    > Swift Unwrapped
    23 — @basthomas

    View Slide

  24. THANKS!
    @BASTHOMAS
    24 — @basthomas

    View Slide

  25. REFERENCES
    Swift 5.0 goals
    SE-0143: Conditional conformances
    SE-0157: Support recursive constraints on associated types
    SE-0176: Enforce Exclusive Access to Memory
    ABI Stability Manifesto
    Ownership Manifesto
    String Manifesto
    Chris Lattner's Concurrency Manifesto
    Moya
    Swift Weekly Brief
    Swift Unwrapped
    25 — @basthomas

    View Slide