Published: March 10, 2022 • 2 min read
Auto-formatting code is good, and you should be doing it all the time. Why? It helps you write better code in real time, it preempts trivial discussions, and it helps democratize programming.
Secondly, auto-formatting flattens the amount of trivial style debates on teams. When I was programming before auto-formatters became widely used on the frontend, many conversations centered on style. Do we include a trailing comma on an object or hash? Tabs or spaces 😈? Code isn’t a style showcase; it’s a tool to provide value. And from that perspective, most distinctions like this do not matter.
Finally, I think auto-formatters help democratize programming. Early in my career, I wrote Ruby, a stylistically relaxed language, and honed strong opinions about styles. I believed code should be written in one style, and I was proud to know the rules. I liked that you could recognize a seasoned Rubyist by how well they knew the rules.
Nowadays, I find these debates boring. I’m more interested in what the code does. It’s a uniform: when everybody looks the same, appearance becomes less important than action. Auto-formatters give us a chance to make code about features and creating, rather than expert rule-following.
I love how communities like Elixir and Go introduced built-in formatters. The conversations on such projects are generally about behavior and execution. What a gift! Compare that to a team that’s bikeshedding trivial style choices, or maintaining long configuration file that enforce an ever-changing set of rules. Who’s doing better work? Who’s having more fun?
I spoke about this at ElixirDaze 2018, advocating for Elixir’s (then new) autoformatter. I’m still impressed with that decision.
Auto-formatting is good. Beyond the above arguments, auto-formatters save me untold keystrokes that I’d waste pushing characters around. Install an autoformatter and write better code, reduce meaningless debate, and make programming more accessible.
✉️ Get better at programming by learning with me. Subscribe to Jake Worth's Newsletter for bi-weekly ideas, creations, and curated resources from across the world of programming. Join me today!
Blog of Jake Worth, software engineer in Maine.