3 ms·
> code is easier to read when... This is almost always a subjective opinion. I've worked on many projects where people reformat large portions of the codebase
by yosito 5y ago
> code is easier to read when...
This is almost always a subjective opinion. I've worked on many projects where people reformat large portions of the codebase to make it "easier to read", and in the end they waste a bunch of time, make using `git blame` a pain, and subjectively either make no difference in code readability or make the code harder for half the team to read.
> I'd like the compiler to reformat code...
Why is this the compiler's job? Most people aren't reading code after it's been compiled. In most of the languages I've worked with, this is handled by a formatter + styleguide/config that either runs in the IDE on save or on a git hook, or both.
- gwbas1c 5y ago> Most people aren't reading code after it's been compiled Ever start a new job with a bulk of code you didn't write? Worse, ever take over code written by novices who ignore common conventions? The whole point is to see if having a standard style is easier in the long run.
- yosito 5y agoStill, why would you be reading compiled code?
- sseagull 5y ago> Ever start a new job with a bulk of code you didn't write? Worse, ever take over code written by novices who ignore common conventions? Yes, I have seen lots of this in scientific computing. However, things like too many/not enough spaces, line widths, etc, are never a huge hindrance for me. What does make code "hard to read" are things like bad and inconsistent variable/function/class names, bad inheritance practices, bad file organization, and not adhering to common language idioms. That stuff is rarely, if ever, caught by linters. Great talk by Raymond Hettinger about this: https://www.youtube.com/watch?v=wf-BqAjZb8M https://www.youtube.com/watch?v=wf-BqAjZb8M