No Single Swift Style

By: Jeremy W. Sherman. Published: . Categories: swift.

“Swift is too young for us to say what good Swift style is, or to have developed a sense for idiomatic Swift.”

Talks, blogs, and books repeat this sentiment or variations.

This statement assumes that there will eventually develop a single, canonical Swift style.

This is a mistake.

I expect no single style will develop; instead, several different styles will flourish. Perhaps most developers will be conversant with multiple styles. More likely, these styles will develop into several mutually unintelligible dialects.

What might these styles be?

In addition, Swift’s type system makes it possible to borrow at least some of the approaches pioneered by the ML family of languages, though its lack of support for higher-kinded types and incomplete support for variably-sized enum types can make this awkward to express. With a solid Prelude library to provide basic tools missing from Swift’s standard library, FP in Swift will be a very real possibility. Higher-level FP programming will likely be no less foreign to the other dialects in a couple years than it is today; reliance on FP-specific libraries will not help.

Swift’s styles are being built today by the snippets and libraries that will constitute their core vocabulary.

Some idioms will be common to several styles; some will be unique to a style; some of those will be inapplicable, even inexpressible, in other styles.

Swift isn’t too young to have a style: It’s just too big to be confined to having a single style.