Why I don't like Swift

I don't like Swift, why? Well, some unique features in Swift make it more complicated while bringing little benefit.

More namings

A farameter in Swift functions can have two names: argument labels for calling the functions, and parameter names for using inside the funtions[1]. For example:

func someFunction(argumentLabel parameterName: Int) {
    // In the function body, parameterName refers to the argument value
    // for that parameter.
}

Come on. Why do we need two names for one parameter? With this feature, naming become twice as hard[2] in Swift.

Guard Statement

guard is for early return if one or more conditions aren’t met. The syntax is kind of weird:

guard CONDITIONS else {
    STATEMENTS
}

For about half a year, I just can't get my head around this keyword.

Optional type

Do we really need this? Now Optional types are everywhere in our codebase, and I have to write a lot of more code to handle those cases. Often people use Optional when it's not necessary.


  1. https://docs.swift.org/swift-book/LanguageGuide/Functions.html#ID166 ↩︎

  2. https://martinfowler.com/bliki/TwoHardThings.html ↩︎