3 ms·
I recently integrated clang format into my editor for my personal projects. It is physically impossible for me to write code that isn't formatted to a consisten
by nwallin 7y ago
I recently integrated clang format into my editor for my personal projects. It is physically impossible for me to write code that isn't formatted to a consistent style. I don't even like what the default style is, but that doesn't matter, because it's consistent.
It's made me substantially better as a programmer in my personal projects. I'm typing word salad into the editor, and if it formats it wrong I know I've fucked up and need to fix it. It's comparable to the point in my programmer life I decided that every time I declared a variable I would ask myself whether or not I could make it const, and if I couldn't, why not.
It's made me worse at my day job, where all of a sudden I think of formatting as a purely output mechanism, where my tooling says "I think you mean this", but in my work environment it's an I/O mechanism.
It will be twenty years before I have enough clout at my day job to enforce a uniform coding standard.
- guitarbill 7y agothere's definitely a benefit for this in a team environment. having some kind of consistency makes reviewing easier, not to mention onboarding new people and senior engineers jumping into unfamiliar codebases. even in open source it makes sense. there's a reason go fmt and black (for python) are so popular. for what it's worth, i don't 100% agree with the decisions black makes, either. but luckily, you don't have to see eye to eye to reap the benefits. two caveats: it has to be a robust auto-formatter. something like checkstyle is unsuitable, because it creates more work, not less. and the auto-formatting has to be enforced via CI.