Swift has been developing rapidly in the past two years, and it has exploded since it opened source, supporting Linux as well as iOS. Swift 3.0 will follow later this year. I’m going to talk about what’s coming in Swift 3.0.

Swift has created a Guihub home page for documents related to version updates at github.com/apple/swift…

Here’s a list of Swift 3.0 highlights, and I’ll help you summarize them:

  • More stable ABI

The ABI is a binary interface and is a more low-level mechanism. We’re all familiar with apis, application programming interfaces such as Fun Open (Path: String), which is a function signature that can be compiled as long as our program can find the implementation of this method signature at compile time. In this way, when we want to change the implementation of this method, we don’t need to change the code in our calling layer, we just need to replace the implementation of this method with another library.

The ABI is even more low-level, at the language and system level. If Swift 3 optimizes the ABI well enough, we will be able to reference the libraries compiled in the older Swift language in future releases. There is no need to worry about the Swift language upgrade, many third-party libraries need to modify the problem.

For those of you who have migrated from Swift 1.x to Swift 2, this is one of the goals of Swift 3 and depends on the strength of the community.

  • Resolve fragile interface problems

Fragile Interfaces are a common problem in modern programming languages. Their full name is The Fragile Binary Interface. In simple terms, properties of classes in Swift and most of the current major development languages are accessed by offsets at the bottom, such as book.name. It is very intuitive to access properties of an object in an application. But when it compiles, it actually has the form location(book) + offset(name). The name attribute is accessed by adding an offset to the memory address of the book object.

The class in Swift, when compiled, calculates the offsets of all its attributes. This will speed up the execution of the program at run time, since these offsets need not be computed at run time. This wouldn’t be a problem if all the classes had nothing to do with each other, but in practice, we all have inheritance relationships when we use classes. If our main project references an external library, our main program inherits classes from that external library. So if there are any changes in this library, we have to recompile all the code in the class inheritance tree, otherwise we will have an offset calculation error in the subclasses of our main program.

To put it simply, if Swift 3.0 can handle the Fragile Binary Interface well, the most intuitive feeling for us developers is that it will compile faster.

About the Fragile Binary Interface more detailed content, everyone here if there are interested can refer to: en.wikipedia.org/wiki/Fragil…

  • portability

The simple thing is to get Swift to port to more platforms, and get Swift to write code that runs correctly on all of them.

  • Full support for generics

Most of the features of generics are already well supported in the current Swift release, as you can see from the Swift 2.2 API documentation. However, generics have not been fully implemented yet, so Swift 3.0 intends to fully support all features of generics.

  • Publish API design specifications

This time also released Swift language API design specification. The purpose of this specification is to create a more uniform API, and there are a lot of code specifications in it, which is worth looking at, even if we don’t build an open source library, for our everyday code style. And Swift 3.0 will redesign most apis based on this specification. Understanding this design specification is also very helpful to our understanding of Swift

Design specification Address: swift.org/documentati…

conclusion

Swift is a rapidly evolving language, and the open source community continues to inject power into it. This 3.0 release shows that it is trying to solve some of the most advanced problems in programming languages, such as the Fragile Binary Interface.

This site articles are original content, if you need to reprint, please indicate the source, thank you. If you want to read more exciting content, please follow the wechat public account Swift-cafe and send it to you as soon as possible