Enterprise Mobile App Development : Dallas Fort Worth Metroplex

Swift: The Future of iOS Development

The world of iOS and OS X development is currently dominated by Objective-C, a language developed in the 1980s originally used as the programming language for the NeXTSTEP operating system. It had been the tool of choice for iOS and OS X development until the announcement of Swift at Apple’s Worldwide Developer’s Conference (WWDC) in 2014.

Swift is a programming language developed by Apple to be used for iOS and OS X development. It encompasses modern language paradigms in order to provide more power to iOS and OS X developers. The syntax and features of Swift reflect the popularity of modern languages such as Ruby, Python and Haskell. Yes, it even has familiar functional programming features such as maps and filters.

The biggest difference between Objective-C and Swift is the syntax itself. Swift models the syntax of modern scripting languages. Here is a small example of a Swift program that showcases the new syntax as well as the ability to switch using a String.


var vehicle = "Monster Truck"
switch vehicle {
case "Minivan":
let comment = "I guess it could be worse!"
case "Motorcycle":
let comment = "Don't forget your helmet."
case "Monster Truck":
let comment = "I don't think that is street legal."
default:
let comment = "I don't have any opinions about \(vehicle)"
}

Both functions and closures in Swift provide useful utilities to the developer such as variable number of arguments and nesting while functions themselves can return multiple values using tuples. Returning multiple values is possible using Objective-C by returning some type of collection, but Swift’s implementation makes it much easier and quicker to implement.
iPhone
Unlike Objective-C, Swift treats functions as first-class objects. This means that functions can be returned and passed to and from other functions.

The features of Swift are not new to programming languages, but they are, however, new to iOS and OS X development. Many of these features provide a cleaner and more readable solution while keeping code clutter to a minimum. The goal is to ultimately provide a more efficient tool when creating applications. Less time should be spent on cumbersome implementation details and Swift aims to boost productivity by simplifying the most mundane of tasks.

  • Generics are a very useful tool in programming and provide a way to abstract functions so that they can accommodate multiple data types. Swapping values is a common task used in many programming implementations. Swapping two integers, float values, double values or strings will all require their own specific function. Using generics, an abstract swap function can be created to swap the values of two variables.
  • Type inference is another modern feature adopted into Swift. It allows variables to infer the type based on the expression given. This means that variables now have the ability to take on multiple types instead of being limited to a specific type.
  • Swift is strongly-typed, meaning that each piece of data has a distinct data type. For example, two variables with different data types cannot be added together.
  • A popular feature of Swift is the ability to use Unicode characters in strings. Also, many Unicode characters can be used as identifiers as well.

Developers started diving into Swift after the release of the beta version during WWDC 2014. The new features and syntax are well-received and bring a lot to the development table. We here at Ayoka are excited to start developing new applications using Swift. If you have a developer account with Apple, you can start using Swift right away by downloading the beta version of Xcode. Download it via the Apple developer website. For more information, check out Apple’s documentation.