News for hackers. Stuff that matters.
Re:Linus on Line Breaks (2020) by AprilArcus on Sunday November 28, 2021 @01:01PM (#29371150)
Shorter lines are easier for the eye to visually scan without accidentally skipping up or down during the leftward return saccade.[1]

80 characters happens to be just a little longer than the supposedly ideal measure for continuous text promulgated by Robert Bringhurst.[2]

I take the even more draconian approach of wrapping to 72 columns when writing comments, after the fashion of PEP 8.[3]

Of course, Linus will dictate the style of his projects' codebases as he deems fit.

[1]https://en.wikipedia.org/wiki/Saccade

[2]http://webtypography.net/2.1.2

[3]https://www.python.org/dev/peps/pep-0008/#maximum-line-lengt...

Re:Linus on Line Breaks (2020) by Diggsey on Sunday November 28, 2021 @01:21PM (#29371349)
- Code is not prose. It's not read like a book so it's not clear that an "ideal measure for continuous text" is at all relevant.

- Most lines are short even if the limit is more than 80 characters, so you're unlikely to accidentally shift up or down after reading a long line.

- Even if there turns out to be some benefit for reading code based on Saccades, that means nothing unless you can make some quantitative comparison with the other advantages and disadvantages of a longer line length.

Re:Linus on Line Breaks (2020) by throwawayboise on Sunday November 28, 2021 @01:35PM (#29371508)
For me it's not just the length of the line but the level of indentation. I think wide indents are good for readability, so if you're using standard tabs and also sticking to 80 columns as a hard limit then you have only 64 characters to work with at two levels of indentation. Excessive indentation is a clue that you may want to refactor, but two levels is pretty common.

80 charcters starting at the point of indentation is more reasonable. At two levels of indenting, you might get out to 96 characters, which still fits comfortably in most GUI terminal windows.

Re:Linus on Line Breaks (2020) by AlphaSite on Sunday November 28, 2021 @02:21PM (#29371962)
W is the bare minimum, it’s a function and a conditional or loop, 3 or 4 is pretty common.
Re:Linus on Line Breaks (2020) by xxpor on Sunday November 28, 2021 @03:00PM (#29372353)
The biggest problem with short lines isn't even the line length, it's that it encourages stupid variable names in order to keep things on one line. Silly abbreviations that no one new to the code can figure out are the bane of my existence.
Re:Linus on Line Breaks (2020) by lgrapenthin on Sunday November 28, 2021 @05:02PM (#29373476)
Why does code have to be "read like a book" to be considered "continuous text"? Of course code is continuous text.
Re:Linus on Line Breaks (2020) by tasogare on Sunday November 28, 2021 @10:21PM (#29375997)
No it's not: a book is generally read from cover to cover (at least fiction) while code is split amongst various files. One is free to read them in any order, which is the opposite of continuous text.
Re:Linus on Line Breaks (2020) by lgrapenthin on Tuesday December 07, 2021 @10:32AM (#29473493)
And like with files, you are also free to read chapters of a book in any order. But files have little to do with lines, no? Of course a function definition in every sane language is continuous text, even though you "are free" to read it backwards or starting in the middle.
Re:Linus on Line Breaks (2020) by coldtea on Sunday November 28, 2021 @01:36PM (#29371516)
That's for books.

When reading code, I'd rather see a single statement on one line, rather that break it at 2 lines because it passed some ancient 80 char limit...

Re:Linus on Line Breaks (2020) by nomercy400 on Sunday November 28, 2021 @04:14PM (#29373107)
Thank you. I was looking for this.

I don't care if a line needs to be 180 chars if it starts with log.debug. Just like searching, I read my code globally based on the first 10-20 chars. If I need details on a line, I'll read the whole line.

I do however put chained methods on new lines, because they are often a new statement.

And I use 4 spaces for indent, because my IDE is smart enough, it is in my programming language guidelines, and that's what my comapny uses.

Re:Linus on Line Breaks (2020) by thow_away_soon on Sunday November 28, 2021 @04:20PM (#29373164)
I'd rather not have that statement more than 80 char long; that might be a one liner where many things are happening, in case there _is_ value is breaking it up, or maybe the variable names are too long, not helping readability.
Re:Linus on Line Breaks (2020) by rocqua on Sunday November 28, 2021 @04:42PM (#29373329)
Long variable names can cause long lines.

So can simple arithmetic that would be worse with intermediate values.

Re:Linus on Line Breaks (2020) by d0mine on Sunday November 28, 2021 @02:34PM (#29372122)
"ancient" doesn't mean wrong. Round wheels are ancient, it doesn't mean we should switch to the square wheels.
Re:Linus on Line Breaks (2020) by coldtea on Sunday November 28, 2021 @03:37PM (#29372736)
>Round wheels are ancient, it doesn't mean we should switch to the square wheels.

No, but it means we better use rubber wheels, not stone ones...

Re:Linus on Line Breaks (2020) by cortesoft on Sunday November 28, 2021 @02:53PM (#29372300)
It doesn't mean right either, and the person you are responding to gave specific reasons why they prefer longer.
Re:Linus on Line Breaks (2020) by kortilla on Sunday November 28, 2021 @03:03PM (#29372379)
So it’s almost as if the “ancient” qualifier was useless.
Re:Linus on Line Breaks (2020) by cortesoft on Sunday November 28, 2021 @03:14PM (#29372495)
Well it was clearly meant to imply that the reason we are using it is merely tradition, and that there was a reason a long time ago that no longer applies.
Re:Linus on Line Breaks (2020) by coldtea on Sunday November 28, 2021 @03:37PM (#29372741)
It was intended to mean "relavent in old times".
Re:Linus on Line Breaks (2020) by mayoff on Sunday November 28, 2021 @05:26PM (#29373741)
And we all use 80-column wheels because that's what the ancients used, by Zeus!

Oh wait, we use wheels sized for their use cases…

Re:Linus on Line Breaks (2020) by jlarocco on Sunday November 28, 2021 @06:53PM (#29374585)
Re:Linus on Line Breaks (2020) by hsbauauvhabzb on Sunday November 28, 2021 @05:23PM (#29373705)
We also shouldn’t burn people deemed witches at the stake. Being ancient doesn’t make it right, either.
Re:Linus on Line Breaks (2020) by coldtea on Sunday November 28, 2021 @01:37PM (#29371532)
Even PEP8 says "Some teams strongly prefer a longer line length. For code maintained exclusively or primarily by a team that can reach agreement on this issue, it is okay to increase the line length limit up to 99 characters, provided that comments and docstrings are still wrapped at 72 characters."
Re:Linus on Line Breaks (2020) by indymike on Sunday November 28, 2021 @04:02PM (#29372990)
> it is okay to increase the line length limit up to 99 characters

PEP8 is strongly biased towards making code readable, and has helped a generation of programmers start thinking about readability when coding. The line length limit, though, is one of the few parts of PEP8 that introduced defects as a practice. Holding to 80 characters causes:

* string concatenation bugs from breaking up long strings

* errors in expressions broken up into multiple expressions just to fit

* bias to use shorter variable names

My favorite part of PEP8 was the warning about "foolish consistency".

Re:Linus on Line Breaks (2020) by unixhero on Sunday November 28, 2021 @04:31PM (#29373239)
Are we supposed to be reading the PEPs?
Re:Linus on Line Breaks (2020) by novok on Sunday November 28, 2021 @04:56PM (#29373438)
If you care about the reasoning behind whatever feature they are implementing.
Re:Linus on Line Breaks (2020) by GoblinSlayer on Monday November 29, 2021 @03:38AM (#29377600)
Comments suffer even more from line length limit. I saw it many times when a comment is changed and then all following lines get rewrapped.
Re:Linus on Line Breaks (2020) by jagger27 on Sunday November 28, 2021 @01:26PM (#29371398)
> I take the even more draconian approach of wrapping to 72 columns when writing comments, after the fashion of PEP 8.[3]

Which also happens to be how Linus wrapped the lines of this particular email.

Re:Linus on Line Breaks (2020) by SonOfLilit on Sunday November 28, 2021 @04:01PM (#29372978)
Plaintext email is wrapped to 72, that's in the RFC - Linus didn't have much choice there.
Re:Linus on Line Breaks (2020) by rhn_mk1 on Sunday November 28, 2021 @05:57PM (#29374082)
Sure did:

> Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

https://datatracker.ietf.org/doc/html/rfc5322#section-2.1.1

https://www.arp242.net/email-wrapping.html

Re:Linus on Line Breaks (2020) by dan-robertson on Sunday November 28, 2021 @08:01PM (#29375103)
I think I heard somewhere that the studies about line length don’t actually give very strong evidence in favour of short lines. On the other hand, I don’t have a source for that. Do you know if they are any good or is this just repeating common wisdom?

Some arguments in favour of longer lines would be:

- monospaced fonts are relatively wide so the line is not long in terms of the number of characters

- there can be a lot of non-length on the left hand side due to indentation (especially in Linux where tabs are wide)

- programmers are relatively literate and so might perform better than average at finding the start of the line

- editor features like line highlighting can help to find the line

- source code has a very ragged edge and so it is easier to find the start of the line than in dense prose.

- magazines or their readers prefer narrow columns for stylistic reasons. E.g. newspapers sometimes have very narrow columns that lead to intraword spacing that makes things hard to read

Re:Linus on Line Breaks (2020) by weego on Sunday November 28, 2021 @02:31PM (#29372093)
1) has tenuous relevance at best

2) The 80 or 66 char or whatever is literally a non-science driven designer rule of thumb that's actually the opposite conclusion from results of actual research into the issue (granted it's not exactly a deeply studied niche but there is research).

Re:Linus on Line Breaks (2020) by lobocinza on Sunday November 28, 2021 @06:53PM (#29374588)
Arbitrary line breaking is ugly and a unnecessary source of errors. I avoid writing lines longer than 80 chars but in some cases it feels better and more ergonomic/readable to exceed it.
Re:Linus on Line Breaks (2020) by tpoacher on Monday November 29, 2021 @07:20AM (#29378972)
It depends. This is not an unbroken rule.

E.g. if you have 4 long lines all following the same pattern with minor modifications, the best way to both scan quickly and avoid bugs is to write them on their own line fully and align the common parts vertically.

Splitting each line into smaller parts for the sake of "vertical scanning" actually achieves exactly the opposite in this case.

Re:Linus on Line Breaks (2020) by lenkite on Tuesday November 30, 2021 @06:00AM (#29390893)
Book lines are not indented at different nested levels while code is. So, unless your line limit is 72char+indentation, it makes little sense to follow this deeply cumbersome policy which will result in developers making single letters for all variables and 2/3 letter function/method names.
Re:Linus on Line Breaks (2020) by phil294 on Sunday November 28, 2021 @03:25PM (#29372621)
When "visually scanning" code, in 90% of the cases, only the first 10 characters matter anyway, so I fail to see your point. How often do you really need to grasp, say, all function arguments at once?
Re:Linus on Line Breaks (2020) by michaelcampbell on Sunday November 28, 2021 @03:50PM (#29372873)
These opinions about readability "flow" using numbered footnotes strikes me as the height of irony, but that's me.