(*) Unless you are OK with the formatting rules they impose on you.
This article makes the case that opinionated code formatters like Prettier and Biome, and the argument they make that providing customizable formatting rules only serves to enable bike shedding arguments between coders, is a fallacy.
Code formatting is a topic that is dear to many programmers who have spent years working on huge code bases, because they help teams maintain a consistent format and, as a result of that uniformity, can greatly help with code readability. I put the emphasis on code readability here because this is the true value that formatters provide. The easier it is for programmers to read each other's code, the faster they will be at understanding it.
The specific formatting rules that are enforced by a formatter, and whether they make code more or less readable, is a highly subjective thing. For example, whether you think that putting an 'else' on the same line as the closing curly brace instead of a new line, is more or less readable is a matter of personal preference. Perfectly valid arguments could be made for one way or the other.
if(i === 0) {
// do something
} else {
// do something else
}
or
if(i === 0) {
// do something
}
else {
// do something else
}
However, just because something is subjective doesn't mean that it's not valuable, or that all point of view are equal. The value of a point of view is in the eye of the beholder. If my team is used to putting an "else" on a new line, then that's the valuable formatting rule for us. It would be pointless to argue about it. If your team is used to code that is formatted a certain way and a new hire changes all the code base's formatting by installing Prettier, you will get a lot of teeth grating from the coders who are used to the in-house style and have come to expect things to be formatted a certain way. Arguing that everyone should just accept the formatting rules picked by some tool author that doesn't care about the way you do things just means that your own subjectivity aligns with that of the tool author. Good for you! Too bad for everyone else who thinks the opinionated format is less readable.
Who are the opinionated formatter's authors to decide what's best for everyone else?
Dismissing everyone's subjectivity by imposing the subjectivity of the authors of the formatter does not provide any value. Giving users the option to customize the formatting doesn't take anything away from teams that are perfectly fine with using the defaults. The reverse is not true. If Prettier/Biome were configurable, team leads could enforce internal formatting rules in its configuration files and not have to worry about rogue devs installing one of them and reformatting the whole code base.
A formatter should concern itself with enforcing the rules that fit users of that tool, not that of the authors of the tool.
A closer look into the bike shedding argument
Such debates over code formatting might be something people do on the Internet, but in real work scenarios, that's not something I have seen happen. This feels like a straw man argument to justify imposing your own subjectivity on others. On all projects I have worked on, the lead developer decided the (ESlint) formatting rules enforced on the project and that was never up for debate.
The value of a formatter is in enforcing the rules that makes the code more readable for you. Dismissing someone's else's need to use different rules as bike shedding, or an example of tragedy of the commons, is short-sighted at best, arrogant at worse. Whatever formatting rule choices these tool authors have made is what they think readable code should look like. It doesn't make the code universally more readable for everyone.
Prettier & Biome VS ESlint
Where I work, we use ESLint as a formatter because it allows us to customize the formatting rules to what we consider to be more readable, and it works perfectly fine for our needs. So you might ask: "Why don't you just keep using ESLint and let everyone else who likes opinionated formatters use that?". Well, this rant came as a result of learning about Biome, a formatter that is written in Rust. I installed it to see how much faster it is and got immediately excited about the noticeable difference compared to other formatters written in JavaScript. As a developer working on huge code bases, I often find the performance of some of the tool chain (formatters, linters, etc.) sluggish, and I'd like to adopt anything that makes my workflow faster. But as soon as I looked at the limited formatting configuration options, I immediately discarded it as yet another thing that doesn't recognize my subjectivity as valid and valuable.
I doubt it will make the authors of Prettier and Biome change their minds, but I hope that if someone decides to port ESlint to Rust in the future, they will not take the easy road of imposing one-size-fits-all formatting on us. The tooling ecosystem should provide more options, not less.
Top comments (3)
For example case, google java formatter makes the following statement in the code "The goal of google-java-format is to provide consistent formatting, and to free developers from arguments over style choices. It is an explicit non-goal to support developers' individual preferences, and in fact it would work directly against our primary goals."
Okay, seriously what arguments? The only people I have ever seen argue are the ones that want to impose their preferred style on everyone else. And hello! just use a formatter and format it the way you want it, I'll use a formatter and format it the way I want it. Hell, format it automatically upon check-in and I'll format it when I check it out. But don't make a single choice formatter and think you have accomplished anything good.
You know what other entity eliminates argument by restricting everyone to a single (their) choice? DICTATORS! One reason dictatorships fail is lack of diversity/innovation/choice.
I've come to the conclusion to only contribute the absolute minimum to projects that enforce their coding style on others, be it in the form of autoformatters (git hooks) or not accepting code that "isn't in the sacred format".
I will uphold everyone's right to accept code in their liking as long as it works right and doesn't need to be touched on. As much as everyone complains that "it's not standard", those are excuses of laziness to me, not wanting to read someone else's coding style.
Programming is an art form if you do it right, and automatic code formatters are shitting on top of your code, becuse "muh standardized format".
I use flake8 standards but what black does in the python world for example, is simply akin to Nazism to me.
I don't think the Nazis killed Jews because they were using formatters. Seriously, you should reconsider using references to Nazism to express your disagreement, unless the person you are talking to is being a racist / hater.
To answer your other arguments: If you work in a team on a project that has hundred of thousands of lines of code, any amount of time programmers save by not having to deal with people's personal preference on formatting is time saved to do something that's actually useful. It’s not about laziness, it's about efficiency.