Should there be a recommended style? Yes
Should there be an official formatting tool that enforces this style? Yes
Should that official formatting tool be configurable? No
Should the official formatting tool be optional? Yes
My concern is that configuration flexibility will result in fragmented styles. When you then attempt to leverage code that conforms to a different style, you're no farther ahead. That said, I know I haven't used languages that enforce styling, and I'm concerned that many of us expressing opinions haven't spent significant time in languages where code-style-enforcement is accepted.
So I asked a friend who has been learning Swift and has significant experience with code-style-enforcement. Here's what he had to say, and I think it was well said.
In any language, there are stylistic opinions that can be backed up with heuristic measurements. Then there are things that are basically preference. The former are usually easy to get past, but the latter can be what creates unnecessary obstacles for teams.
If a team's preference is unified and consistent then there is no real issue. Otherwise, I've found it's better to enforce consistency and adopt the code's conventions than it is to frequently battle the overhead of mixed style. This overhead comes from reading, reviewing, OCD fixing, and discussing. This cost is compounded when adopting various open-source libraries or code from other parts of the organization.
When the language itself determines the preferences, everyone just gets used to it and formatting wars just...go away. It makes it much easier to adopt or contribute to other codebases.
Next, the language tooling can build enforcement into the build process. IDE's can auto-format and compilers can check format. So now nobody spends any time formatting code.
And what is best, nobody spends any time making or fixing picky formatting comments in code reviews.
This has been my biggest complaint about learning swift...every example I read uses different horizontal and vertical spacing preferences. When I borrow code from one project, I have to comb through it to adjust spacing or someone inevitably spends time having to ask me to correct it (and I'm just thinking, "...but I used an example we borrowed from this other project...").
...and then concurrently working on an Elixir project where a simple
mix format formats all the code perfectly, the difference is very stark.
Yes, we need an official Swift style
Yes, there should be an official tool for applying formatting
No, the style shouldn't be configurable or you're no further ahead in terms of mixed styles between projects and dependencies.
Yes, when developing you should be able to ignore the styling (temporarily) and then apply the formatting once you're ready to clean things up.