Happy B-Day, SWIFT! - Questers

Happy B-Day, SWIFT!

Today is a special day in the world of programming because we celebrate the 9th anniversary of the official introduction of Swift, a high-level, general-purpose, multi-paradigm programming language developed by Apple Inc. and the open-source community. However, it was first introduced to the world at Apple’s 2014 Worldwide Developers Conference (WWDC), as an alternative to Objective-C – a 30 years old well-known language used by Apple for the OS X (MacOS) and iOS operating systems. Swift was designed to be modern, faster, more secure and interactive. And as its creators claimed at WWDC 2014 it is way faster than Objective-C and Python.

Over the years, the language has quickly gained popularity among developers thanks to its modern syntax, speed and safety features. It has become the main language for developing iOS, macOS, watchOS, and tvOS apps. In addition, it also has vast usage in server-side programming, machine learning, and others. In the famous Stack Overflow Developer Survey, Swift was voted “Most Loved Programming Language” in 2015 and took second place in 2016.

Supported by an active and enthusiastic community of developers, the programming language continues to evolve and grow. With every new release, Swift strives to improve the programming experience by making it more intuitive and efficient. On March 30, 2023, the new Swift 5.8 was officially released. It lays the foundation for Swift 6 with feature previews such as concise magic file names, forward-scan matching for trailing disclosures and regex literals. The highlights of Swift 5.8 also include an upgraded developer experience and improved Windows support.

In this article, we take a look at the major improvements of the new release, so let's dive in:

  • Concise magic file names (ConciseMagicFile). This update will allow #file to be evaluated to a human-readable string containing the file name and the module name while preserving the existing behavior in a new #filePath expression. Currently, #file evaluates to a string literal holding the full path to the current source file.
  • Regex literals (BareSlashRegexLiterals). This feature enhancement provides compile-time checks and type-capture inference.
  • Forward-scan matching for trailing disclosures (ForwardTrailingClosures). The new update replaces backward-scan matching with a forward scan, for simplicity and better API support.
  • Introduces existential any (ExistentialAny). The way existential types are currently spelled in Swift is very lightweight, using just the name of a protocol as a type. However, this simplicity has led to some confusion and has often caused programmers to take the wrong approach, ultimately requiring them to rewrite their code when they encounter limitations with value-level abstraction. To address this issue, a proposal suggests making the impact of existential types more explicit in the language. This would involve annotating such types with the keyword "any" making it more apparent when working with existential types in Swift.

In Swift 5.8, a conditional attribute capability is also included, which promises to reduce maintenance costs for libraries supporting multiple versions of Swift tools. Other language and standard library enhancements are also available, including unboxing for all optional parameter arguments and improved debug printing for key paths. The result builder implementation has been reworked to improve compile performance, code completion results and diagnostics.

Furthermore, SwiftSyntax has a redesigned parser implemented entirely in Swift instead of relying on the C++ parser create the SwiftSyntax tree. This new parser offers advantages in areas such as error recovery.

For Windows, Swift 5.8 provides a lot of improvements, such as reducing the dependency of the Windows toolchain on environment variables. In addition, the original work on C++ interrupt support in Windows has been merged and is available in the toolchain. This includes work on modularizing the Microsoft C++ runtime.

There are promising signs of Swift’s bright future and with the Worldwide Developers Conference coming up soon who knows… the announcement of Swift 6 may not be impossible.

field_tagged: