top | item 33258954

(no title)

jwdunne | 3 years ago

Yes, I find it harder to read code at lengths much longer than this. 120 is quite difficult. It also makes it even harder to read if you split the screen vertically, which I do all the time.

That said, I don’t think it should be a hard limit and it’s fine if a lines a bit over, +/- 10 like you said. Certainly not something that we should contort into multiple lines just to keep under a hard limit. Unfortunately, a few auto formatters only do hard limits - it’d be interesting to see how an acceptable interval around the limit would work.

Plus, I’ve noticed the limit makes more of a difference for comments than code so I try to keep comments under that. The written word appears more sensitive to line length.

discuss

order

pizzaburek|3 years ago

For my personal Python projects I set a hard limit in the 94-96 range. That's wide enough that I actualy adhere to it instead of just ignoring it.

PEP8's and Google style guide's limits of 79 and 80 are way to narrow for a language with 4 space identation. However PEP says that "it is okay to increase the line length limit up to 99 characters" while Google's 80 is just a soft limit that can be broken in certain cases like long URLs.

bruce343434|3 years ago

How do you envision an interval around a limit? The fact is that you have to draw the line somewhere. If your interval is +-20, then setting a "limit" of 80 is really just a hard limit of 100.

alpaca128|3 years ago

By letting the code formatter exceed the limit if it allows for more readable formatting in certain cases. Going for a 100% hard limit means sometimes it'll shuffle chunks of code around because of 1-2 characters and that just doesn't make a lot of sense.

Or in other words, by formatting the code more like a human than dumping the source tree with a blind set of rules. If Copilot is possible then so is an AI model able to consider how code actually looks on the screen.