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

A Swift Introduction to Swift

A Swift Introduction to Swift

Swift has been among StackOverflow’s “most loved” languages every year since its 2014 release. With examples from the MongoDB Swift driver, this talk will highlight unique, powerful features of Swift, and discuss the challenges of writing good code in a young, flexible and rapidly changing language. Attendees will come away informed about some of the advantages and challenges of writing code in Swift. They will be better prepared to write idiomatic Swift of their own, and will have a deeper understanding of how a MongoDB driver works.

Kaitlin Mahar

June 26, 2018
Tweet

More Decks by Kaitlin Mahar

Other Decks in Programming

Transcript

  1. Protocols • Similar to an interface in other languages -

    specify a required set of properties and methods • A type that implement those requirements conforms to the protocol • Classes, structs, and enums can all conform
  2. How to represent BSON values? Double String Document Array Binary

    ObjectId Boolean Date Regex CodeWithScope Int32 Timestamp Int64 Decimal128 MinKey MaxKey
  3. How to represent BSON values? Double String Document Array Binary

    ObjectId Boolean Date Regex CodeWithScope Int32 Timestamp Int64 Decimal128 MinKey MaxKey
  4. Challenges of Swift’s type system • Lacking some desired features

    • Auto-generated ==, hashing (new in 4.1) • Conditional conformance (new in 4.1.. ish) • Default type parameters (someday?)
  5. In summary… • Swift is new and exciting! • Swift

    has a powerful type system: protocols, extensions, generics, optionals, and more. • Swift interoperates easily with C. • You should try writing Swift!
  6. What’s next for the driver? • 1.0 release • Full

    CRUD API • 4.0 features • replica sets, etc. • Integration with Swift web frameworks • Replace libbson usage with native Swift
  7. Want to learn more? Today: 3:30-4pm MongoDB Mobile session in

    Gibson On your own: The Swift Programming Language (by Apple, free) objc.io videos and books Swift by Sundell (blog)