Swift Program is Swift, Except When it’s Not


This past WWDC Apple revealed a brand new programming language called Swift to the masses and passed it out to Apple Developers packaged in the XCode 6 Beta.

Language Features

  • Type Inferencing and Automatic Reference Counting (ARC)
  • Optional Bindings and Generic Functions
  • Integration with Objective-C
  • First-Class Functions and Closures

My initial impressions were pretty high. However, after some quick benchmarking examples, those feelings later matured to an understanding of it’s "beta" characteristics. Many of the underlying optimization still have some kinks to work through.

And by kinks, I mean some big fixes


Here are a couple examples of ...
Read More....

Swift: Bubble Sort

// Sang Han
// An implementation of a bubble party/bubble sort written in swift

import Foundation

func exchange<T>(inout a: T, inout b: T)
    let tmp = a
    a = b
    b = tmp

func bubbleSort(inout array: [Int]) -> [Int]
    let length = array.count

    var count, pos: Int
    for (count=0; count<length-1; count++)
        for (pos=0; pos<(length-count-1); pos++)
            if (array[pos] > array[pos+1]) {
                exchange(&array[pos], &array[pos+1])
    return array

func sortMain(arrayLength: Int) -> [Int]
    var array: [Int] = []
    for _ in 0..<arrayLength {
    return bubbleSort(&array)
Read More....