top | item 36834241

(no title)

jdrek1 | 2 years ago

I don't, I think that line length limits are typically not a good idea and thus I don't like hard limiting them. Now obviously arbitrarily long lines are no good, I'm not advocating for people to write 300+ char lines. I'm just saying that sometimes there's good reasons to (slightly!) go over the "limit", for example shortening the variable name "users" to "usrs" to make a n+1 line fit into the n char limit would be a terrible idea. And also when this topic comes up then typically people implicitly think about the 80 char limit, which is just way too restrictive and has no reason to exist anymore, it's not 1980.

The limit on what constitutes a reasonable line length is a bit subjective but I'd say that well written code rarely goes above ~120 or so. Depends a bit on the language, some just have more boilerplate than others. But instead of making that a hard limit I'd warn above that number so actual people can decide if it makes sense there or if a rewrite is in order. Auto-formatting is great and all, but ultimately a human should have the last decision.

Though if you force me to pick a value, then it's 4 because that's the sanest choice for like 95-99.9% of all people.

discuss

order

No comments yet.