Another day was the launch of the so-called "spring forms" of all systems and combinations of some cool features such as mouse support and track track on iPadOS.
But along with the versions of the program, comes the update in the development: Xcode 11.4 with major upgrades and upgrades that make it the stable version of Xcode 11 we've been waiting for since September, with the arrival of the latest version of Swift Language: version 5.2.
Let's briefly review all the news it provides.
Major improvements in the language have not changed in that, since Swift has a stable API since version 3 and about 99% of the code generated from that version will continue to work on this version.. What Apple has done is significantly improve the "guts" of the language by developing and introducing new functions that allow for better analysis and error detection while writing our code.
Design of buildings
The first thing that has been done is to change the language structure of the language into a new and improved one. This design is what allows us to analyze the code as we rewrite it identify errors on or before compiling our system.
Apple has improved the language use experience with a new diagnostic feature that allows more information on errors in the code, as well as faster corrections for most of those errors.
If you've worked with Swift, it's known that sometimes its "accuracy" in presenting a problem in the code wasn't the best. And that's the problem was very angry when SwiftUI arrived its structure DSL (domain-specific language) has changed the standard representation method to be used for the specified library.
Apple, aware of the problem, has been working for many months to install a new building engine which will tell us precisely where the error is, and not only that, it will also suggest a lot "fixes" (quick fix) for the code to be edited and displayed as appropriate.
We use the example from Apple itself, in the previous version, when we created the following code:
enum E
{ case one, two }
func check (e: E) {
if he is! = .three {
print ("OK")
}
}
In this code we created two possible values: one
y two
. Nothing else. But in practice check
we ask for an understanding amount three
which is obviously not. So far, the error that has been given to us has been about an unequal distribution operator (the !=
) where it tells us that both types of data are incompatible because they found themselves to be different. Bad error.
With the new version of the engine, it will tell us exactly what the price is three
is not on display E
, why we can accurately understand the problem.
This is just a small example to get an idea of this radical change that will help us make code analysis more accurate, more accurate (and faster, because the basic algorithm itself has been improved) where are the code errors.
As a complement to this change, the code completion engine was also greatly improved, suggesting what code to write when writing it (and consequently not always remember the exact name of the hundreds or thousands of methods, variables or objects we have in our system, and the libraries we use). This engine improved its efficiency between 1,2 and 1.6x checks eliminating painful checks.
LSP is an open source standard developed by Microsoft that seeks to create a single open standard when operating and implementing code control solutions in any programming language.
More responsible for this change is the construction of the LSP (Language server protocol) from Microsoft which Apple has installed for marking, processing, and code completion. When Apple uses this technology, in short, any editorial or third-party software (such as Sublime Text, Visual Studio Code or IDEs such as Visual Studio) you can automatically complete, analyze and manage code in Swift in the same way and with the same engine that Xcode uses, which provides a very stable experience even among different applications.
Integrator development
Integrating the system with its speed is an important task. That's what translates our code into something programmatic can understand. Here Apple has installed batteries again greatly improve the speed of integration processes end (release) and making a mistakedebugging).
For this to be possible, improved two widely used methods: one that goes up (which detects and only integrates real code changes between compilation and compilation, and thus improves the test duration of our program) and optimizes the complete module (or WMO) used when we want to create the final version our program and that put all code in one file, to work it out for the perfect link.
This change has been included great bug fixes which allows us to run our system on-line, to see its performance while it is working and to extract data that helps us detect errors during operation.
Encoding
This release, Apple has added two exciting features to the language. One of them is the opportunity to use the function called callAsFunction
within any category or structure. For its use, it is focused on the upcoming Swift and Python collaboration where Google runs its TensorFlow engine machine learning, allows us to call continuous or variable when the instance of a class or structure is stored, as though it were a function.
struct Dado {
var caras:Int
func callAsFunction() -> Int {
Int.random(in: 1...caras)
}
}
let dice1 = Given (heads: 8)
let result = given1 ()
As we can see, we created an example of struct
Dado
, and we can run it as a function by calling dado1()
without explicitly showing the employee's name since callAsFunction
it serves as a function that is relevant to the model itself.
Apple has included only two language changes in this version: the version has been explicitly named from the root of the model and the main method in the functions that get the root data.
Also, in practical applications we can use the new method of divination within the highest order functions of the operating systems, as well as any other explicit function that receives the data instance as a parameter.
Before you use the short parameter $0
followed by a building name (such as $0.name
) and now we can use the reference by using a the main method and backsliding: .name
, he thought .
compatible the model root obtained by the parameter. It's a small semantic development that makes the clues clear.
Minor improvements
Without a doubt, Swift is one of Apple's most promising projects in every way and where it puts great effort and effort. Not only the company itself and all companies that use this language as an open source language, and it's an unbelievable community that proposes practical, remedial, incremental improvements …
From here, thanks to all for the good work they do.
Table of Contents