Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

How to write apps with Swift 3

Lucy Hattersley | July 13, 2016
All you need to know about writing apps with Apple's Swift 3 developer language: the importance of Swift going open-source, new features in Swift 3, and why you should you learn to program in Swift

If we look at the classic Hello World program in each language (the program that writes "Hello, world!" on the screen). You can see that Swift is simpler, and makes much more sense than Objective-C.

Objective-C: Hello World

Here is how the Hello World program appears in Objective-C:



#import <Foundation/Foundation.h>


int main(void)


    NSLog(@"Hello, world!\n");

    return 0;



Swift: Hello World

Here is how the Hello World program looks in Swift:

println("Hello, world!")


As you can see Swift is a much cleaner and simpler code to read and learn. Here are some other features that Apple lists as important to ensuring code is expressive:

  • Closures unified with function pointers
  • Tuples and multiple return values
  • Generics
  • Fast and concise iteration over a range or collection
  • Structs that support methods, extensions, protocols.
  • Functional programming patterns, e.g.: map and filter

Apple Swift's memory is managed

One of the big advantages to Swift is that developers do not have to manage memory allocations. In Swift variables are initialized before use, arrays and integers are checked for overflow and memory is managed automatically. This makes the Swift programming language safer to use for developers who aren't quite as experienced. Swift's memory management will make apps more reliable, which will benefit developers and non-developers.

How to write apps with Swift 3: Where can I get Apple Swift for my Mac?

Swift is part of the Xcode IDE (integrated development environment) available as a free download from the Mac App Store.

Xcode-6 Beta Icon

How to write apps with Swift 3: Should I learn how to program in Swift?

The general consensus from developers appears to be that Swift is a great programming language. Swift is similar in many ways to Python, another highly-regarded programming language. Swift should be a much easier programming language for newcomers to pick up than Objective-C. Python is regularly used as the language of choice for programming classes, so many programmers may already be familiar with much of the Apple Swift syntax.

But it's also better for established developers who will find the cleaner syntax easier to use.

If you've spent time becoming familiar with Objective-C you should find much about Swift that makes life easier, although having to move to a new programming language requires learning new code, which will be a distraction for current developers. But in the long run Swift coding is expected to pay off even for seasoned Objective-C developers.

Swift is not going to make it easy to move code from Mac OS X and iOS to other platforms, such as Android. Many developers are weighing up the advantages of Swift development against further lock-in to the Apple environment. For the time being Apple is supporting both Objective-C and Swift code for building Cocoa and Cocoa Touch apps, but eventually we expect it to move everybody over to Swift.


Previous Page  1  2  3  4  5  6  Next Page 

Sign up for CIO Asia eNewsletters.