The change of swift3.0

Source: Internet
Author: User

Swift in the 2 years, the momentum of development, after its open source, it is like a blowout, in addition to IOS, Mac platform, but also support Linux. In the second half of this year, Swift 3.0 will be released as well. Https://github.com/apple/swift-evolution details the characteristics of 3.0.

The main objective of this release is to enhance the stability of the language's binary interface and the standard library, as part of this process, we will improve the swift language to provide the overall consistency of the experience and execution (feel and implementation), and Swift 3.0 will contain 2 pairs of 2. The change in X source-breaking, more specifically, focuses on several key areas:


I. Stable Abi (Stable Abi)


A stable ABI is provided to ensure forward compatibility, which involves the data structure at runtime, name mangling, calling convention (calling conventions), and so on.


The stable ABI also extends to the standard library, its data type, and the core algorithm. The stability of the successful ABI means that future swift versions of applications and libraries can be compiled at the swift3.0 binary level of applications and libraries, even if the source language changes.

Second, strong ability to expand adaptability, for the subsequent version of the Foundation (Resilience)


The so-called fragile interface, is a common problem of modern programming language, its full name is called Fragile Binary Interface. In short, the properties of the classes in Swift and most of the current mainstream development languages are accessed at the bottom through offsets, such as Book.name, which is very intuitive for us to access the properties of an object in the program. But after compiling it, it is actually the form location (book) + offset (name). The Access Name property is implemented by adding an offset to the memory address where the book object resides.


Then the class in Swift is compiled, and the offset values of all its properties are computed. This speeds up the execution of the program at run time, because it does not need to be computed at run time for these offsets. There is no problem if there is no association between all the classes, but in practice, we use classes to have inheritance relationships. If we refer to an external library in our main project, we inherit the class from this external library in our main program. So if there are any changes in this library, we have to recompile all of the code above the class inheritance tree, otherwise the offset calculation error will occur in the subclass of our main program.


Simply put, if Swift 3.0 can handle fragile Binary Interface, the most intuitive feeling for our developers is that it's faster to compile.

Third, portability (portability)


The simple thing is that Swift can be ported to more other platforms, and the code written by Swift can run correctly on all of these platforms.

Iv. Reorganize the type system (type systems cleanup and documentation)


Re-set the type conversion rules, and their implementation in compiler type checking, with the aim of a smaller, simpler type system, more rigorous definition and more reliable type checking.

V. Full support for generics (complete generics)


Full generics can enable Swift to provide better scalability, especially for standard libraries. The current version of Swift already supports most of the features of generics, which you can see in the API documentation for Swift 2.2. But the generic features are not fully implemented yet, so this time Swift 3.0 intends to fully support all the features of generics.

Vi. Focus and refine the language


Focus on the language itself, improve the language is not good place.

Vii. API Design Guidelines


The API design specification for the Swift language is also released this time. The purpose of this specification is to let you design a more unified API, which gives a lot of code specifications, which is well worth seeing, even if we do not build open source libraries, it is very helpful to our everyday code style. and Swift 3.0 will redesign most APIs according to this specification. Understanding this design specification is also helpful for us to understand the Swift language.

The change of swift3.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.