I deal with the same kind of frustrations (in both directions) when switching between the Swift and Kotlin.
As others have mentioned, some of your examples can be optimized but not others. My perception is removing much more syntax in Swift will encounter significant pushback from the community (see SE-0257: Eliding commas from multiline expression lists - #190 by Braden_Scothern and Allow function definitions to omit parentheses if no parameters - #5 by allevato )
One thing to keep in mind as a (non-satisfying) reason is how Kotlin treats everything as an expression, while Swift has semantic differences between Properties, Functions, Methods, and Closures differently. That, along with a more complex memory-management system I believe means some of the syntactic sugar you get for free in Kotlin is significantly complex to implement in Swift.
Swift is also designed for clarity and safety, while Kotlin sacrifices some amount of those for a more flexible and script-like syntax. So although I would love to do things in Swift like this:
func add(_ left: Int, _ right: Int) = left + right
func add1(to value: Int) = add(value, 1)
func addIf0(value: Int) = switch isAllowed {
case 0: add1(to: value)
default: value
}
there are reasonable arguments that it's much less clear what's happening, and therefore less safe.
Anyway, my guess is that type of syntax isn't coming to Swift anytime soon, just like static
properties/methods, enum
associated values, and turnery statements probably aren't coming to Kotlin.