X
Business

Swift, Apple's language of choice, gets a major refresh

With all the other Apple news, you may have missed that Apple released the latest version of its Swift programming language: Swift 5.0
Written by Steven Vaughan-Nichols, Senior Contributing Editor

With all the news that Apple wants to be your streaming provider and your credit-card company, plus there's yet another iOS release, you may have missed that Apple also has some old-fashioned technology news. Apple has released the newest version of is flagship language: Swift 5.0.

Also: Apple event 2019: Apple Card, TV Plus, News Plus, Arcade CNET

Swift is Apple's open-source, general-purpose programming language. It replaces C-based languages (C, C++, and Objective-C) for everything from systems programming to mobile and desktop apps all the way up to cloud services. Specifically, you can use it to develop programs for the iOS, macOS, watchOS, tvOS, Linux, and z/OS platforms. Swift  also works with Apple's Cocoa and Cocoa Touch frameworks and a great deal of existing Apple Objective-C code.

In this latest version, Swift 5 is source compatible with its predecessors, the Swift 4.x variants. MacOS's integrated development environment (IDE) Xcode 10.2 includes a code migrator to help with source code changes. Besides the macOS Swift 5 toolchain, you can also develop with Swift on the Ubuntu Linux family.

The most important update in Swift 5 is that its application binary interface (ABI) has been standardized and made stable across macOS, iOS, watchOS, and tvOS. What does that mean for you? It means you can develop an app built with one version of the Swift compiler and be certain it can work with a library built with another version. Thus, you'll no longer need to embed the Swift standard library and "overlay" libraries within your application. Instead, your application will use your operating system's Swift runtime and standard library.  This also means your downloads will be smaller.

Swift 5's standard library also now includes the following new features:

  • String reimplemented with UTF-8 encoding, which can often result in faster code
  • Improved support for raw text in string literals
  • Result and Single instruction, multiple data (SIMD) vector types added
  • Enhancements to String interpolation, adding more flexibility to construct text from data
  • Performance improvements to Dictionary and Set

To help Swift more secure, this latest edition also comes with runtime checking of "Exclusive Access to Memory" on by default. The net result is that it "eliminates dangerous program interactions involving mutable state and action at a distance."

This just touches the surface of Swift's changes. For more, see the Swift migration guide and the updated The Swift Programming Language manual. Want to play with Swift 5? Paul Hudson, writer, programmer, and head of Hacking with Swift has created a Xcode Playground to play with Swift 5.0.

It was the best of Apple, it was the worst of Apple

Related stories:

Editorial standards