26 C
Jaipur
Saturday, October 24, 2020

Swift System Is Now Open Source With Linux Support

Must read

iPhone 12 Users Can Now Download OS Updates Over 5G Data

Apple finally introduced 5G support with the launch of its latest iPhone 12 series. Now, as iPhones support high-speed 5G networks, the Cupertino tech...

Check Out Oppo Find X2 League of Legends Special Edition Right Here

After much anticipation, Chinese phone maker, Oppo unveiled the second generation of its Find X series, the Oppo Find X2 and Find X2 Pro,...

apple: Apple fixes 6 malicious apps posing as Adobe Flash installers – Latest News

The malicious apps masquerading as Adobe Flash installer are not going to go away anytime soon as Apple has once again fixed six more...

Back in June this year, Apple engineers introduced Swift System — a new library to interface with low-level currency types and system calls. Today, Apple open-sourced Swift System and also added Linux support.

The idea behind Swift System is to present a one-stop solution to low-level system interfaces for all supported Swift platforms. So let’s check out what’s new in it:

Leaving Imported C Interfaces Behind

The majority of the operating systems we use today work on support some type of system interface written in C and it has remained the same for decades. These APIs can be used directly from Swift, but such weakly-typed system interfaces imported from C are prone to error and are unmanageable.

For instance, in UNIX-like operating systems such as Linux and Apple’s OS, weakly-typed functions have several cons and they fail to utilize the expressivity and type safety one can find in Swift.

Also Read: Swift Programming Language Now Available On Windows 10

Introducing Idiomatic Swift Interfaces

The Swift System module introduces several language features to improve expressivity and reduces the chances error. For e.g. System defines the open system call as a static function with defaulted arguments in the FileDescriptor namespace:

On comparing this version to the original version in C, you can spot significant differences such as:

  • System uses raw representable structs and option sets. Such strong types help in identifying mistakes at compile time and are easier to convert to and from the weaker C types.
  • Errors are thrown using the standard language mechanism and cannot be missed.
  • FilePath is a managed, null-terminated bag-of-bytes that conforms to ExpressibleByStringLiteral — far safer to work with than a UnsafePointer<CChar>.

It is important to note that System is not a cross-platform but a multi-platform library. It provides a separate set of APIs and behaviors on every supported platform, which closely reflects the underlying OS interfaces. Therefore, a single import will pull in the native platform interfaces specific for the OS you choose.

The post Swift System Is Now Open Source With Linux Support appeared first on Fossbytes.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

iPhone 12 Users Can Now Download OS Updates Over 5G Data

Apple finally introduced 5G support with the launch of its latest iPhone 12 series. Now, as iPhones support high-speed 5G networks, the Cupertino tech...

Check Out Oppo Find X2 League of Legends Special Edition Right Here

After much anticipation, Chinese phone maker, Oppo unveiled the second generation of its Find X series, the Oppo Find X2 and Find X2 Pro,...

apple: Apple fixes 6 malicious apps posing as Adobe Flash installers – Latest News

The malicious apps masquerading as Adobe Flash installer are not going to go away anytime soon as Apple has once again fixed six more...

smart speaker: Global smart speaker market to reach 163 million units in 2021: Report – Latest News

Led by Amazon Alexa and Google Assistant powered devices, the global smart speaker market (including smart displays) is set to reach 163 million units...