In the recent days, there was a fair amount of hatred towards Swift. It seems a lot developers shipped their iOS 8 updates and started using Swift to implement features or new Apps. That’s great, and I totally did the same but you have to adjust your expectations on how your experience will be.

In limited ways it’s possible to write Swift like Objective-C without the brackets. All the Foundation, Cocoa and Cocoa Touch Objects and APIs are available. But you’ll start to stumble after a few steps. Optionals will be a huge pain at first. Some language features aren’t really there or work entirely different. (KVO and Arrays for example). That’s the reason why you shouldn’t write Swift like you write Objective-C. I remember the problems I had when I started with Objective-C and iOS development, because it was just 3 years ago. I knew some Python and the basics of Java when I started. You can image how confused I was: Pointers everywhere, the responder chain, id,…, the list can go on forever. Now everyone is in a similar situation again. We can’t expect to be 100 percent productive from day one.

This is the perfect opportunity to rethink the way we used to write our code. We are now in the unique position on actively defining the future of the language we will use for coming years or decades. We can do it by filing bug reports and feature requests, actively discussing best practices with blogposts, in the developer forum or even on Twitter.

It feels like I can see a bit of the future when I look at this beautiful code by Matt Thompson for his AFNetworking-succesor Alamofire

enum Router: URLRequestConvertible {
    static let baseURLString = "http://example.com"
    static var OAuthToken: String?

    case CreateUser([String: AnyObject])
    case ReadUser(String)
    case UpdateUser(String, [String: AnyObject])
    case DestroyUser(String)

    var method: Alamofire.Method {
        switch self {
        case .CreateUser:
            return .POST
        case .ReadUser:
            return .GET
        case .UpdateUser:
            return .PUT
        case .DestroyUser:
            return .DELETE
        }
    }

    var path: String {
        switch self {
        case .CreateUser:
            return "/users"
        case .ReadUser(let username):
            return "/users/\(username)"
        case .UpdateUser(let username, _):
            return "/users/\(username)"
        case .DestroyUser(let username):
            return "/users/\(username)"
        }
    }

    // MARK: URLRequestConvertible

    var URLRequest: NSURLRequest {
        let URL = NSURL(string: Router.baseURLString)
        let mutableURLRequest = NSMutableURLRequest(URL: URL.URLByAppendingPathComponent(path))
        mutableURLRequest.HTTPMethod = method.toRaw()

        if let token = Router.OAuthToken {
            mutableURLRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
        }

        switch self {
        case .CreateUser(let parameters):
            return Alamofire.ParameterEncoding.JSON.encode(mutableURLRequest, parameters: parameters).0
        case .UpdateUser(_, let parameters):
            return Alamofire.ParameterEncoding.URL.encode(mutableURLRequest, parameters: parameters).0
        default:
            return mutableURLRequest
        }
    }
}

I’m incredibly excited about Swift and love writing code in it. It’s possible that it will be the only choice we have to develop native applications for Apple products, so why not start today?