What’s the deal with Swift?(in my best Seinfeld voice)


1)The first big thing that comes up in almost every article I’ve read is that Swift isn’t finished, it still has important features that are actively being built and tested.

Example from the Huffpost article linked below, author Ahmed Eid states “ Currently in Swift, anything you declare in any class is automatically public and available to every other class. At one of the labs at WWDC, we asked an Apple Swift engineer if it’s possible to make a property private, (that can’t be altered from a different class), and we were told that this is indeed coming in the next few months”. (as of 6/13/14)

Programs written in Swift also cannot be released until Xcode 6 is ready, which is still in beta and won’t be ready before iOS 8 / Yosemite ships.

source: http://www.huffingtonpost.com/ahmed-eid/apples-swift-is-great-but_b_5492239.html

2) Swift can be experimented with in an interactive environment called “Playgrounds”. This tool allows the programmer to view the effects of changes or additions to code as you type, without having to run and execute code for every change.

3) The continued importance of objective- C when working with Swift:  If you want to use C/C++ libraries in Swift you will still need to talk with the libraries using OB-C. Apple made it possible for Swift and OB-C AND C++ to all coexist in the same app, so a given program could be written in 3 different languages.

4) The frameworks are written Objective-C. A programmer might have a hard time finding bugs until execution is deep in Apple’s code. If you want to understand what the debugger is telling you, you will need to understand Objective-C.

source: http://www.bignerdranch.com/blog/ios-developers-need-to-know-objective-c/

This bignerdranch article also talks about which program may be easier to learn. The author states that having a solid foundation in Objective C will make learning Swift much easier!

5)  Nitty Gritty: Technical differences of Swift

A) Type Inference: Programmer doesn’t need to annotate variables with type       information. The compiler infers it from what value is being set to the variable.

B) Generics: in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided asparameters.

C) Containers: In Objective-C, arrays and dictionaries can contain any type you want. But in Swift, arrays and dictionaries are typed. And they are typed through the use of Generics.

D) Mutability:. There are no “mutable” counterparts to Array and Dictionary. A programmer will use the standard let and var. Let is used to declare a variable as constant, and var is used to declare a variable as a variable. Let is like using const in C/C++/Objective-C.

E) String functionality:Swift makes dealing with strings much easier to handle. For example,  you can concatenate strings easily using “+=” and compare strings using “==” instead of the having to type out “isEqualToString:”. Strings can also be used in switch statements.

F) In an article published by Javaworld, which is linked in the sources below,  author Paul Rubens explains another big change for Swift,  Tuple’s: “ A tuple lets you group multiple elements into a single compound variable. The values in a Swift tuple can be of any type and don’t have to be the same type as each other. You can make a tuple from any permutation of types that you like: (Int, Int, Int) or (int, String) or (String,Bool) or whatever else you need. There are a number of ways to get the values in a tuple. You can access them by index number (starting with 0), for example, or you can decompose a tuple into separate constants or variables.”

G) Control Flow: The switch statement has been significantly updated in Swift and can now match against ranges, list of elements, boolean expression, enums amongst others. It doesn’t fall through by default, and is further enhanced by Swift’s flexible pattern matching.

H) Optionals: An optional type is a type that might contain a value of a type. It allows you to more easily convert between types and avoid null checks. Optionals can be chained together to protect from exceptions when calling multiple methods or properties in a chain where one call might return “nil”.





6)Apple attempts to make Swift a safer language. Programmers must include brace brackets to open and close “If” statements. This change will prevent a variety of  bugs such as theSSL “goto fail” error.  Switch statements also must include a default statement. This will make sure that something will run at the end of the statement even if none of the possibilities in the statement are satisfied.

7)  Apple’s new iOS 8 SDK will include over 4,000 new API’S. From the Apple link below, these are a few of the new and exciting API’s Swift will offer:

  • PhotoKit, so developers can tap into the power of the same robust framework as the built-in Photos app for faster performance, nondestructive edits and the ability to both read and write to the Photos library;

  • new Camera APIs, giving developers fine grain control over focus, white balance and exposure;

  • CloudKit, a complete and scaleable back-end solution helps developers eliminate the need for writing server code and maintaining servers; and

  • new App Store™ features for developers like app previews and app bundles, the new iTunes Connect with free analytics and TestFlight for beta testing pre-release apps.

  • HealthKit, combines health data to help you take better care of your health

Source: https://www.apple.com/pr/library/2014/06/02Apple-Releases-iOS-8-SDK-With-Over-4-000-New-APIs.html

8) Other Links:

Official apple book on Swift: Free download: https://itunes.apple.com/us/book/swift-programming-language/id881256329?mt=11

Apple Developer Tour of Swift: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html

5 best Swift tutorials: http://www.skilledup.com/learn/programming/5-best-free-swift-tutorials-programming-new-language/

This entry was posted in native and tagged on by .

About DJ

Dj is a Computer Science major at City College of San Francisco. He has focused on learning Java and Mobile Development. Dj loves music, traveling, reading and baseball.