@phaylon wrote:
If I have a tool to keep that consistency, I’ll use it. If the tool insists on putting things in a style that I find harder to read, I won’t run it.
Then fight to make the default rustfmt standard nice to read for you. In particular, don’t fight about everything, fight about what really is important to you (what would make rustfmt completely unusable in your situation).
@Diggsey wrote:
- If a formatter is too strict, it’s more likely to divide people on whether they use it at all rather than creating a uniform style.
I think this is not an argument against having a single style, but rather about how to enforce it (Python enforces some style via indentation at the interpreter level).
I doubt this is a problem tho. Everybody uses gofmt and basic Python style. In which language with a single default style did this division happen?
- Cannot improve the formatter in a backwards-compatible way: with per-project settings you can maintain a system-wide up-to-date version of the formatter, and just not update the settings file for projects whose formatting you don’t want to change.
First, note that having a setting files won’t be enough to ensure that formatting doesn’t change, since a bugfix can change the resulting formatting even in this case.
The best solution I’ve seen is what clang and clang-format do: sync the release of rustc with that of rustfmt. New language features require a new rustfmt version anyways. The only difference is that the commit message when upgrading a project to a new version of rustc would look like “upgraded rustc to version X, upgraded project version to Y, reformatted” instead.
Bugs in the formatting tool are a real issue. It took clang-format one year of full time development to reach a point where new features and bug fixes have minimal impact on the resulting format. Rust is simpler than C++, so hopefully this will happen faster. The solution here is to not start enforcing rustfmt until it has stabilized and making it opt-in till then.
Some settings are more than just a personal preference - they may actually affect the usability of some editors. For example: spaces vs tabs, 80 chars per line limit, import style, etc
This is not an argument against a single stye, but about the details of that style. There are combinations of these settings that work on all editors, all environments, … (spaces, 80 char limit, …). In particular, there are already a lot of tools designed for the minimum common denominator. By trying to go above that we make rust unusable in those environments. For example, there was a reddit post about the Calendar example in Rust. A solution to this problem was posted on github: https://gist.github.com/DanielKeep/7c87e697d5810803d069
I find it insane that I have to scroll to the right here on a 27`` monitor because github does not support lines this long (1k characters?): https://gist.github.com/DanielKeep/7c87e697d5810803d069#file-bin-rs-L27
rustfmt should make sure that you can always read and edit your rust code everywhere, so if the proposed style doesn’t allow you to do that, argue against it.
@rkjnsn wrote:
Line length is a good example. While 100 is great for many environments, sometimes there are limitations that make it less than ideal (such as if you often need to view your code in an 80-column terminal, for instance), and it would be nice to have the flexibility to change that setting. (I find that 90 characters works best for my common development machines, so that’s what I use for personal projects).
This is not an argument against having a single style line, but about a particular detail of that style line. If you are against 100 character limit, argue against it. If you are in favour of 90 character limit, argue for it. I will argue that 80 character limit works for everybody (see the gist above for an example of tools not coping with a given character limit).
To all three of you:
Seriously, if every single project I’ve been in was able to agree on style, we can agree on a single style for rustfmt too!
Even if this style is not perfect to each one of us, as long as it is usable, we’ll be able to live with it. Every developer is able to adapt to different styles on different projects.