How do you handle it in your code base?
Usually I prefer to read 80 columns format, but some terms I really want to write fully in one line for readability....
--
Srdja
To 80 column or not to 80 column?
Moderator: Ras
-
- Posts: 3233
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
-
- Posts: 467
- Joined: Fri Dec 16, 2016 11:04 am
- Location: France
- Full name: Richard Delorme
Re: To 80 column or not to 80 column?
My code editor shows a margin at column 120, but some of my code lines occasionally cross that margin.
In my opinion, the 80 column is something from the past when screens were limited to 80 columns. On a 4K screen, 200 columns are easily readable. Of course, I do not mean that code should be compacted to fill the 200 columns at each lines, but I prefer a function declaration that span over 100 columns with meaningful function and argument names than a function that fit in the 80 column with confuse abbreviations.
But, as the proverb says, "There's no accounting for taste".
In my opinion, the 80 column is something from the past when screens were limited to 80 columns. On a 4K screen, 200 columns are easily readable. Of course, I do not mean that code should be compacted to fill the 200 columns at each lines, but I prefer a function declaration that span over 100 columns with meaningful function and argument names than a function that fit in the 80 column with confuse abbreviations.
But, as the proverb says, "There's no accounting for taste".
Richard Delorme
-
- Posts: 4398
- Joined: Fri Mar 10, 2006 5:23 am
- Location: http://www.arasanchess.org
Re: To 80 column or not to 80 column?
I remember Linus Torvalds had a comment about this - he wasn't in favor of 80-col limits, since modern displays can easily handle more than that.
-
- Posts: 1872
- Joined: Sat Nov 25, 2017 2:28 pm
- Location: France
Re: To 80 column or not to 80 column?
Google style guide says
One good argument for staying at 80 for me is the double columns diff for git commit inside gitlab or github ; line wrap in there makes code review horrible.
but indeed, as screen have evolved, my own clang-format config file readsLine Length
Each line of text in your code should be at most 80 characters long.
We recognize that this rule is controversial, but so much existing code already adheres to it, and we feel that consistency is important.
Those who favor this rule argue that it is rude to force them to resize their windows and there is no need for anything longer. Some folks are used to having several code windows side-by-side, and thus don't have room to widen their windows in any case. People set up their work environment assuming a particular maximum window width, and 80 columns has been the traditional standard. Why change it?
Proponents of change argue that a wider line can make code more readable. The 80-column limit is an hidebound throwback to 1960s mainframes; modern equipment has wide screens that can easily show longer lines.
80 characters is the maximum.
A line may exceed 80 characters if it is
a comment line which is not feasible to split without harming readability, ease of cut and paste or auto-linking -- e.g., if a line contains an example command or a literal URL longer than 80 characters.
a raw-string literal with content that exceeds 80 characters. Except for test code, such literals should appear near the top of a file.
an include statement.
a header guard
a using-declaration
Code: Select all
ColumnLimit: "150"
-
- Posts: 263
- Joined: Wed Jun 16, 2021 2:08 am
- Location: Berlin
- Full name: Jost Triller
Re: To 80 column or not to 80 column?
I think it's pretty safe to use 120 columns, but much above that it will become an issue for notebook users. I would also say, that at some point you would need to move your eyes too far to just read a line; I find it is often easier to recognize code when I don't have to move my eyes a lot to read it.