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.

A0b320a5ad7c553eb90070d1a968aab3?s=128

Kaitlin Mahar

June 26, 2018
Tweet

Transcript

  1. 13.
  2. 28.
  3. 29.

    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
  4. 33.

    How to represent BSON values? Double String Document Array Binary

    ObjectId Boolean Date Regex CodeWithScope Int32 Timestamp Int64 Decimal128 MinKey MaxKey
  5. 34.

    How to represent BSON values? Double String Document Array Binary

    ObjectId Boolean Date Regex CodeWithScope Int32 Timestamp Int64 Decimal128 MinKey MaxKey
  6. 39.
  7. 40.
  8. 41.
  9. 44.

    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?)
  10. 45.

    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!
  11. 46.

    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
  12. 47.

    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)