-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: update cppline limit to 100 #45033
Conversation
@nodejs/cpp-reviewers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Line 47 in da8f618
ColumnLimit: 80 |
It's deliberately restrictive, always has been. It forces you to write more succinct code. Longer line lengths optimize for writability, shorter line lengths for readability. Code is read more often than it is written. |
My main concern right now is the |
Signed-off-by: James M Snell <[email protected]>
96975d9
to
4822b44
Compare
I'm not convinced it would be an issue. At least, so far the experience with the quic pr has been pretty painless with this. I'd suggest we could go with this as an experiment. Rolling it back would be fairly straightforward if necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mulled this over but I really don't like flowery prose - you know the kind, interminable run-on sentences that take up half a page - and the same goes for code. Hemingway > *
Added tsc-agenda for discussion. If there are technical reasons not to make the change, that's one thing, but the objections raised so far appear purely subjective. @tniessen raised a possible technical issue that bears consideration. |
just for the sake of discussion, I disagree with
in many occasions reading the beginning of a line can spare you from reading the entire line. for example,
especially when |
Case in point, in the quic PR, I had to shorten... int err = nghttp3_conn_add_write_offset(connection_.get(), stream_data->id, datalen); to int err = nghttp3_conn_add_write_offset(connection_.get(),
stream_data->id,
datalen); I find the shorter lengths far less readable than the longer alternate. |
Looking at it in isolation in the GitHub UI, the single line is more readable. As someone who exclusively works on a small screen and frequently looks at git diffs in my terminal, I disagree that it's more readable while I'm trying to do actual work though. |
I dislike restricting the line length to 80 characters in general, but nonetheless the research that has been done bears out what Ben said: Keeping the lines to 80 chars or less improves readability. Granted, almost everyone who cites the research cites (I think) a single study (but multiple papers) by Buse & Weimer. So you might argue that the data on this topic is thin. You might also argue that a study done in 2008 may not reflect the reality of modern code bases. You might also argue that maintainability is different (albeit related) to readability and this improves maintainability because (for example) we don't have to reformat lines copied/rebased/cherry-picked/whatever from other code bases. And so on. But for Ben's point, what data there is backs up Ben on this as far as I am aware. Keeping most lines shorter than 80 characters correlates strongly with code readability (although there were some other elements that correlated more strongly in Buse & Weimer's research). And I say that as someone who dislikes 80 character line length limits. (100 or 120 seems reasonable to me.) |
I mean, of course - the compiler doesn't care about line length but I, as someone who reviews a lot of code, definitely do. W.r.t. #45033 (comment)
For me it's completely the other way around. My eyes just kind of start to glaze over 2/3rds in. |
@jasnell Just to clarify my (possibly unfounded) concern: C++ PRs have often been much larger than necessary recently to pacify |
@tniessen ... ah, yeah, that's a good point. I had no intention of making it so that existing code would need to change but adjusting the formatter would absolutely have that impact... and for that reason alone I'll withdraw this. |
(On the other hand, if this is something that we'd want to do eventually, I don't know if waiting is going to give us any benefit.) |
The existing 80 has become rather restrictive.