Exercício sobre Swift

★ 7 reasons to switch from Objective-C to Swift

ADVERTISING REPORT

per Leandro Cissoto

In mid-2014 Apple surprised everyone by announcing its new programming language. Call Swift, it arrived with the proposal to replace Objective-C in iOS and OS X development.

Through social networks it was possible to follow the most varied reactions on the part of the developers, some extremely excited by the novelty; others more afraid. The truth is that Swift has been gaining more and more followers and in almost a year of existence it is already being used by many applications.

Here are seven great reasons to use Swift for iOS and OS X development.

1. Playground

Swift

O playground was announced along with Swift language and allows us to write codes with the results being displayed instantly. It is a great way to test code blocks, functions, classes and many other things without the weight of a complete project, allowing from simple logic to more robust and complex blocks.

2. It is modern and flexible

Swift has concepts that modern programming languages ​​can offer: type safe, uses the concept of Optionals to handle null values, doesn’t require a semicolon at the end of each line, has better memory management, works with closures, generics, tuples, subscripts, among others.

3. Speed

Swift speed

Just a few searches on the internet to find several benchmarks comparison between Swift and Objective-C. In the vast majority of them, Swift has a good performance advantage. Apple itself, in announcing the language, highlighted this.

4. great for functional programming

Functional programming is not new, but it has been among the most talked about topics in the development world. It is a programming paradigm that treats computing as a set of mathematical functions avoiding changing states and data, combining flexibility, power and the clarity of abstraction.

Swift functional programming

With Swift, it is possible to mix object orientation with functional programming. Although it is not a fully functional language (as it allows us to develop imperatively), the language has special functions to facilitate the use of functional programming, such as functions map and filter.

5. Fewer files in the project

Swift uses only .swift files other than Objective-C, which creates a header .h, normally used for declaring properties and methods; and an .m file, where these properties and methods are implemented. This halves the number of code files generated in the project, as well as improving performance, as the compiler does not need to read the header.

6. Ease of learning

Swift's syntax is simple and efficient, and its writing will be clean, allowing us to produce more in fewer lines of code. In addition, it has many similarities with other programming languages ​​making developers feel comfortable with its syntax. Apple also took care to facilitate integration with Objective-C, so as not to harm the developers who migrated from it.

7. a path of no return

Swift is here to stay. Many applications that were made in Objective-C are being ported to Swift due to the greater ease and dynamism that the development brings in it. Although the vast majority of App Store applications are on Objective-C, the community's interest and enthusiasm about the possibilities with Swift is growing and certainly the future of the language is very promising, as it is the future of iOS development, OS X and Apple Watch.

· · ·

Liked? Come learn to program in Swift on Quaddro. The school offers the largest training in Brazil with only 280 hours of course and more than 150 applications developed during classes, with classroom and online classes!