Swift Open-ended general-purpose programming language created by Apple and the company’s present and future commitment. Apple has just launched on the official language page the first preloaded image for official download of the language in its new version 5, within the thread of development versions, which is usually renewed every 2 weeks with a new compilation.
Swift is a language that went from being closed after its release to being open language in 2015 (December 2) and is now the banner of Apple’s educational programs to boost programming in schools around the world. A programming language that, contrary to what one might think, does not only serve to create apps for Apple’s operating systems. Swift also works on Linux, on Windows (if we install the Linux subsystem), it is able to work on IoT devices through the latest Raspberry Pi models and its Raspbian system and its last landing has been on server-side applications (or backend) where we have some frameworks (libraries) made in Swift that allow us to create servers that work in AWS (Amazon Web Service), Heroku or IBM Cloud, among others.
Swift is a language that was released to everyone’s surprise on June 2, 2014, and has gone to a larger version with different changes that have evolved every year since then. Every September with the new major version of iOS, a new version of the language arrived. At least this has been the case until Swift 4, because this year in September the released version of Swift was a smaller version, 4.2. The reason? Swift 5 represents a very important milestone for language and the first step for its promising future. Since Swift in this version will achieve something that all languages that are taken seriously must achieve at some point in their evolution: binary stability.
It’s still in a transition period, but the trend is clear, and Swift 5 will definitely replace Objective-C. It should be ready now. If you already know Objective-C, switching to Swift 5 is not difficult. Many concepts in Swift already exist in Objective-C.
Isn’t Objective-C necessary to learn? it’s not true. Swift has not solved the problem of mixing with C and C ++ well. Many projects’ underlying core libraries will use C/C ++, the interface and most of the logic will be written in Swift, and Objective-C will be required as the glue layer. In addition, many libraries are written in Objective-C. Using these libraries requires some Objective-C knowledge.
Over time, Swift will account for more and more code in the entire iOS/Mac project, and Objective-C will still exist as an adhesive layer. Objective-C’s syntax is unique. Even if it is written in the same file as C ++, it will not be confused. It is easy to mix Objective-C with C ++. Swift calls C code just barely (not convenient enough), but calling C ++ directly is not possible.
Many people haven’t learned Swift yet, and don’t think it has any advantages, it’s just a language hodgepodge. Just wait for you to actually write a project or two in Swift and you won’t be able to look back. Swift has some simple and fast writing methods, which cannot be done in Objective-C. And some language features of Swift avoid many Objective-C pitfalls. Any function written in Swift can also be done with Objective-C, but it will be much more cumbersome. And if it is too troublesome, knowing that it is goodwill not do it.
Many things that you haven’t seen before will feel unnecessary. But once you’ve come into contact with swift, you can’t bear to lose it again. I looked at programing project 7 or 9 years ago, when the project had not yet adopted ARC. Now it seems that if there is no ARC, the code is too cumbersome to write. At that time, there was no more advanced writing, and there would be no such feeling. Swift is more advanced than Objective-C.
Advantages of Swift over other programming languages
Swift is Apple’s quintessential programming language. This was presented at the WWDC14 (“World Wide Developers Conference”) of 2014. And after these years, we have already reached the 5th version of this language (swift 5.1) that could be considered innovative in certain aspects.
Features of Swift 5, Apple’s programming language
As we have just said, Swift 5 is a young programming language. Apart from the filing date, June 2014, another important date is December 3, 2015. What happened that day? Apple released Swift under the Apache license, and this programming language became free software. With this, anyone can download the latest version on their official website. As well as the source code from the Apple account on GitHub.
And what is Swift 5 used for? This programming language can be used to program multiple systems. But mainly it is used to program applications for iOS, macOS and more Apple systems. That is, it comes to replace Objective-C.
Swift vs Objective-C, who wins?
Now let’s analyze what advantages Swift has over an older and more traditional language. To facilitate the comparison, we chose Objective-C as the subject, since it performs the same function.
Compatibility with the same libraries as Objective-C
To facilitate adaptation to the new language, Apple made its new programming language compatible with the same Objective-C libraries. In addition, C functions can also be called, as in their predecessor.
As a general rule, the more modern a programming language is, the easier it is to program, although there are obviously exceptions.
This new programming language brings certain features that make it safer than other languages.
This is achieved by preventing certain structures or conditions that cannot be created. In this way, code that in other programming languages can be perfectly valid, in Swift it would give an error to avoid giving rise to a security breach. In fact, this feature would have avoided Apple’s problem in the past with SSL certificates.
In addition to increased security, it also includes improvements in performance. In this way, tasks such as encryption are performed much faster.
And why is it that one programming language is more powerful than another? This is due to several factors, but perhaps the most important is the proximity to the hardware. The closer the programming language is to the computer hardware, the more powerful it will be (that is, the lower the level). This is partly because more optimizations can be applied.
The future of Swift beyond Apple
But the thing does not end there, because binary stability guarantees a future of Swift beyond Apple. A future like the one Microsoft made a few years ago in its Build for developers’ conference: include Swift as another language to be used in Visual Studio. Those of Redmond only put that obvious condition: that the language was stable at the binary level. This is to load the library into the Visual Studio ecosystem and support the MSBuild compiler that already supports third-party structures such as Clang, like Swift, so incorporating the language would not be technically complicated.
As a last curious note, to get an idea of the magnitude: the new operating system Fucshia from Google, which is called to be the substitute for Android, has support for Swift officially (within the current state of development in which it finds).
Now available on GitHub
We can now go to the project on GitHub or the official Swift page and download this new version. If we do it for Linux, it is very easy to install because you just have to pre-install the Clang support with the system package manager and then unzip the downloaded file. If it is on Mac it has an installer and the Toolchain will appear as available in Xcode to be able to use it even in the Playgrounds and try the code changes in it, which are not many but have curious novelties that improve it even more.