Unit is the worst naming

Not exactly. The Never type is not a subtype of all types, therefore it is not the same thing as Kotlin’s Nothing type.

For example, as far as I know in Swift you cannot implement Kotlin’s TODO function – this program results in error: cannot convert value of type ‘Never’ to specified type ‘String’:

func TODO() -> Never {
    fatalError("This is not implemented yet")
}

let f: String = TODO()

That being said, there is a Swift proposal open to change this which specifically references Kotlin’s Nothing type in a positive way.

The names reflect the purpose in the language – in Kotlin its the bottom of the type system, and in Swift its used for functions that never return. Nothing is a noun and Never is an adverb, and types are usually nouns. Swift is also considering making Never a bottom type – if they do that, their naming will sound weird/wrong unless they introduce a new type.

Yep, naming is hard, but IMO Kotlin made the right decision here.

We’re just circling back to prior discussion now.

2 Likes