What’s new in Swift


Swift Project updates

Expressive Code

  • If-else/switch can now be used inline – this simplifies initialization and other conditions
  • Improved error messages and more directly aligned to where the problem is.  (This will come in handy in SwiftUI)
  • Swift Generics allows for type identification preservation, this has been extended to handle # multiple argument types.  So no longer will you be limited to the number of arguments to be passed. Now use <each Result>
  • Macro System –
    • Macros are APIs so you can import module that defines them
    • @Observable macros is key to turn a class into fully observable in your code. (Expand on Swift Macros session)

Swift everywhere

  • Low ceremony code to make it easier to scale
  • Future of Foundation – starting a rewrite of Foundation for Apple and non-Apple platforms.  This is moving the implementation of Swift to Swift.
    • Drives major performance updates across calendar (20%), date formatting (150%), and JSON coding (200-500%)
    • New opt-in capabilities which focus on code ownership. Check it out on the swift forums
  • You can now interoperate between C++ and Swift now. There is a Swift Forum that is being driven by a WorkGroup focused on this.
  • CMake now support Swift and can e used to mix and match C++ and Swift make files, there is a sample Repo to help you get started
  • Actors and Concurrency
    • This section explained synchronization, how the actors and tasks behave

Case Study

,