3 ms·
(Note: I mostly write Java these days, so my viewpoint is colored by this.) Code is meant to be read by humans. Compilers don't have wetware eyes. Homogenizing
by altgeek 5y ago
(Note: I mostly write Java these days, so my viewpoint is colored by this.)
Code is meant to be read by humans. Compilers don't have wetware eyes.
Homogenizing code that was hand-formatted for the situation ignores the art and craft of writing software.
I think formatters do have use as a "base" (e.g. Allman or K&R curlies?), especially for junior devs, but experienced developers that care about their software that has their name on it normally put their best foot forward. They would strive to present the most readable software they can put forth.
I've been writing software since 1981 and have yet to meet a code formatter that I like. `// @formatter:off` !
- Daishiman 5y agoOne man's "readable code" is another person's trash. As the number of commiters in a codebase increases, the chances that you find at least one person's code to be an irritating annoyance increases exponentially. The only way to avoid it is to have the political power to call out the team member that's annoying. Easy enough to do if you're the lead and nobody will question your decisions. The worst and dumbest fights I've encountered is with people with 30 years of experience who have diametrically opposed opinions. I _especially_ despise having to call out very senior engineers when their own code misbehaves.
- altgeek 5y agoYes, very true. One has to prove their point of view. It's easier when the engineer in question has proven themselves in the org (I would say industry, but when you arrive at a shop, you generally need to start over.) I should have made the distinction between "senior in years" vs "senior via software admired by peers". Since code is skewed heavily to the left of "read:write", the primary issues that formatting should address are [1] muscular eye fatigue induced by "formatting" or non-formatting that leads to excessive eye saccades (i.e. eyes "jumping" from point to point, or obliquely) [2] formatting that obscures logic leading to cognitive fatigue. Another thought experiment I've used is: Imagine that you replaced [A-Za-z0-9] with squares and made it black and white. Leave the language's keywords alone. Does the shape of the code suggest the logic and flow? etc. That's more in the zone of cognitive load. That's why it's an art and craft, to me. My thinking is also colored by smaller shops, since a stint as a cog in some large orgs burned up my soul. And yes, I've been in a few dumb fights ;)
- d0mine 5y agoFamiliarity improves readability/comprehension. Black is not ideal but one can live with its output and in time the style becomes familiar to everyone.