335 points · by oddline · 6y ago · 322 comments
This study may be helpful:
> This study examined the effects of line length on reading performance. Reading rates were found to be fastest at 95 cpl. Readers reported either liking or disliking the extreme line lengths (35 cpl, 95 cpl). Those that liked the 35 cpl indicated that the short line length facilitated "faster" reading and was easier because it required less eye movement. Those that liked the 95 cpl stated that they liked having more information on a page at one time. Although some participants reported that they felt like they were reading faster at 35 cpl, this condition actually resulted in the slowest reading speed.
The Effects of Line Length on Reading Online News[1]
1. http://psychology.wichita.edu/surl/usabilitynews/72/LineLeng...
For slabs of body copy, I like about 70 characters per line, but anything in the 50-80 range seems good. I also think justified text is harder to read, due to the lack of unique shapes to track on the right side of text — it's far easier to lose your place.
https://graphicdesign.stackexchange.com/questions/13724/reco...
I still often code on a 13" Macbook where I can open a pair of side-by-side windows in my editor with the dock on the side and get about 95 characters into each window. I typically code in Python and use a 4 space tab and a font legible to my 48 year-old eyes w/o reading glasses. On my external monitor, I take advantage of the extra width to open additional windows.
So I dunno, still prefer 80-88 characters for coding, 100 max.
The grep thing seems like a red-herring. Use grep's -A, -B, and -C options to get more context.
There is some truth to this, but it's largely irrelevant. When text is laid out for books, it's based on a fixed width and each sentence follows the next. Code isn't laid out that way, with code, each statement starts on a new line which naturally limits line width.
Good programmers gravitate towards shorter lines of code by nature. If your average line of code is wider than 80 characters, it's likely you have some other, bigger coding style problems which need to be addressed.
But having the option to use longer lines when it makes the code more readable is also valuable. Putting a fairly short, arbitrary limits on line length just makes other parts of coding less pleasant, variable names in particular suffer quickly when you can't make comparisons on a single line.
Where I work, we wrap lines at 120 characters but the overwhelming majority of the code is less than 80 characters wide. Longer lines are reserved for if statements with multiple conditions or ternary assignments.
This kind of thing is really obtuse and it drives me insane that so many people subscribe to ideas like these.
This kind of thinking is what leads to linters with completely arbitrary rules telling me how I should solve my own problem.
Me: "Hey linter, I'm going to shadow a variable name here, because that's the right thing to do in this situation, so shut up about it."
Linter, and 5 billion HN commenters: "you're shadowing a variable. Compile warning."
Me: "it's a language feature, and it's ok to use."
Linter: "you're shadowing a variable. Compile warning."
Etc.
Arbitrary rules like line width (and I assure you, those rules ARE arbitrary) help exactly 0 people per day, and cause problems for more than 0 people per day.
I PROMISE that a human brain is better at discovering general code quality problems than the best linter with the best rules, and that will be true until a time when every reasonable computer is a general purpose AI.
Yes, tell me when I have a memory leak. Use static analysis to tell me about weird issues I have difficulty seeing. I know best about line width and how to solve things in my own application better than any linter could ever hope to, because linters do not have anything approximating the intelligence of gnat, nevermind a human being.
Linters' line length rules solve a problem of useless bikeshedding and introduce consistence to the code. This already helps everyone involved in reading and writing the code.
I use a linter, it warns about long lines (adjusted to 100), so I reformat or split them and the code seems more readable. Also, it has consistent formatting (other rules), though I occasionally mark some lines to be ignored.
I'd say it helps me, which is >0 people. You don't have to follow norms and/or best practices, but some find it useful.
I have no idea why you think I am arguing for stuffing arbitrary line lengths in code. I was arguing for the exact opposite, that line length limits are rarely beneficial.
I can't agree with that. When you've got class names like AbstractSingletonProxyFactoryBean and similar naming conventions for variables, 80 characters just isn't adequate a lot of the time.
Really, is there any writing that doesn't seem to apply?
In math-heavy stuff, lines tend to be longer. You are usually trying to convert one line of math into one line of code. I myself shoot for 160 character columns.
See, e.g. [1].
When long lines improve readability/ clarity you should have the ability to use them.
As I said above, if your code is loaded down with tons of long lines of code, it's likely a symptom that something else is wrong. If code is difficult to read, it's bad code.
No, it doesn't, especially for code that isn't written in a very basic simplistic imperative style. Expressions have no natural size limits (and statements, in languages that even have them, can generally each contain one or more expressions.)
Languages tend to develop conventional line width limits and conventions for where to prefer to break within expressions to achieve them, but there is no natural length limit to the length of a single statement.
In a 100 char wide code line, how many actual non-whitespace chars would there be on average?
(This invites a rant about people, usually people who use Emacs, who put hard line breaks in text paragraphs, but I'll save it for another time.)
We must strive to separate content and presentation, so people could choose whatever presentation they like (and have the editor do the wrapping as desired), for whatever whimsical reason that is nobody else’s business. It’s crazy to keep having this discussion and debating what the “research” indicates.
C’mon, haven’t we made any progress in forty years!? Everybody can have their own damn bikeshed, and paint it a different color every day.
Personally, I like to see more things happening in one screenful, so artificially imposed line breaks are really really annoying and break momentum when reading/scanning code.
The job of making sure the line length is reasonable is not up to the writer of the code - it is up to the tools that are used to read it. Lines should be as long as necessary, and then intelligently (i.e. syntactically-aware) soft line-wrapped by the editor when opened.
This is not a problem, but a beautiful and crucial property of text files. I like the principle that "a program is a text file", that you can edit with tools orthogonal to the language in question
If I'm glancing at some code on my phone, I can have it set to two space tabs to maximize the amount that fits on screen. If I'm on my desktop they're four spaces because my screen is huge and more visibly apparent indentation is valuable. Same editor, same data. If it's a shared codebase and someone else likes 8 space tabs, 6 space, or whatever they want (13 space? no kinkshaming here...).
To me that is a significant objective advantage of tabs, where the only advantage spaces seem to offer is that you can align text on multiple levels of indentation.
I actually prefer long lines even if I have a small screen and need to horizonally scroll. Often the content at the end of the line isn't even that important.
I find that breaking a line at 80/120 makes the piece of code I am trying to understand less readable, while the line itself may have become more readable.
It's only really since full-screen windows came to play that the issue with Daring Fireball really become obvious; prior to that, macOS users rarely made their windows fill the screen in the same way that Windows users are prone to do.
That would work well enough if the codebase was mostly uniform and all calls to foo were on a single line. However, if we have callsites like "foo(x->y(get_arg(z)), something, \ntrue);" where 'true' is split onto a newline, that naive grep misses it.
As linus says, grep is line-oriented (same for sed, etc). Sure, it's possible to make the output have context, but to actually do a multi-line grep correctly is much more complex.
I think that's the sort of grep usage linus was referring to.
> So I dunno, still prefer 80-88 characters for coding, 100 max.
I also prefer most lines to be under 80 characters, but for the sake of keeping a function call on one line, or keeping important things together, I'm fine with exceptions.
Some code splits onto multiple lines naturally (like moving a function call in a function's arguments into its own temporary variable). Other times, it becomes less readable as several shorter lines.
Thus I don't think a hard rule of 80 is good, simply a general philosophy that readable code is good and that's more important than line length.
Often you combine this with a line oriented but overly false-positive prone query, like a file-level grep for `foo`, since the AST parsing is slower. Then you reprocess with AST-based tools.
There's some fairly ergonomic tooling for this kind of transformation, although often you need a tool per language, which is annoying.
For example for a function foo, it's needlessly hard to grep for its declaration, imports and calls independently. Looking for one will probably surface the others.
That being said, as unlikely that scenario is, having it all in 1 line does not work either. The problem is that its very likely/possible that the true argument will be passed in in the form of a variable. So you’re back to needing something that is more code aware anyways.
This misses the point, same as Linus (which i honestly find surprising)... 80 width lines is a target to try to achieve _naturally_, if someone is splitting code by inserting unnatural breaks then they are trying too hard, OR there could be various other legitimate reasons like very long function names and naturally verbose PL syntax that make even longer line widths unreasonable. Regardless of width constraints many people will split the arguments of extremely long function signatures onto multiple lines out of preference anyway, then grep will still get stuck without more caring regex.
These arguments always emerge out of someone misinterpreting guides as absolutes. No one is arguing we need to stick to 80 column terminals otherwise everyone would autowrap their commits and we'd have horribly unreadable breaks everywhere. 80 is historical, but trying to keep code width short does improve legibility, 80 just turned out to be a pretty good human standard as well.
The post is about changing code style formatting rules for code that goes into the Linux kernel. Not guidelines, rules. The tools in question, I presume to be a linter or formatter, complained noisily about line length prior to the adoption of this change.
It's not about someone misinterpreting guides as absolutes. It's very much about absolutes, in this case, that serve as guides.
perl -pe 's/\\\n//g'
Before grepping foo(1, bar, false)
print("Hello, world")
flag = true
shows up in your grep output, and not in a particularly helpful rendering.The large number of symbols in many languages that are clearly not words in the usual sense might make the comparison a bit tricky, or wouldn't it ?
This is indeed why a large number of books and articles and papers opt for multiple-column formats.
Frequent line breaks also help better break up distinct pieces that warrant independent examination, much like how such breaks in poetry help isolate distinct thoughts. There are certainly cases where such a "thought" does indeed exceed that 80-line limit, but I've found that they are rare (though this obviously depends on the language; for example, in my day job my T-SQL code frequently exceeds that arbitrary limit, simply because it often takes more characters to express a "thought").
All that being said, I wouldn't impose this on an existing project. If Linux's standard is for 100-character lines, then that is the standard to which I'll adhere. For my own code, however, 80 characters is (language limitations notwithstanding) more than sufficient.
They only tested 35, 55, 75, and 95 characters per line (cpl)! Which means that if they had tested 120 cpl, THAT could have been "fastest".
For example, if we had 10 meter-wide monitors we won't be able to see them entirely from a close distance. Increasing the distance will require to increase the font, so the number of characters per line we can use doesn't change much.
Not so long ago I showed a piece of code on a mobile phone to a colleague, saying he should use shorter lines. He replied I need a larger display. When I opened the same code on my desktop display the lines were not fitting the editor window almost the same as on the mobile screen. (The angular sizes of a mobile phone screen and individual characters on it are approximately the same as of the bigger screen and characters on it because we keep phone closer to eyes).
I currently work with a codebase where long lines are used and it is so inconvenient. When I switch to some 80-cols code it is such a relief.
The way I'm set up at my desktop, my editor can fit ~320 columns. Which means I can fit four 80-column-wide files side by side. Three, if you account for line numbers on the margin.
(I usually do two, because my code tends to go up to ~120 characters.)
I remember Linus saying that explicitly.
The restriction on code length to 80 has absolutely nothing to do with the resolution of the human eye or your field of view.
> For example, if we had 10 meter-wide monitors we won't be able to see them entirely from a close distance. Increasing the distance will require to increase the font, so the number of characters per line we can use doesn't change much.
Again, this isn't relevant to the question of say, 80 cols vs 100 cols vs 120 cols. No one seems to be saying cols should be unbounded in length.
> Not so long ago I showed a piece of code on a mobile phone screen to a colleague, saying he should use shorter lines. He replied I need a larger display. When I opened the same code on my desktop display the lines were not fitting the editor window almost the same as on the mobile screen. (We keep phone closer to eyes so can use smaller characters).
I'm not sure how this is an argument for 80 cols other than the already addressed "I limit my development environment to 80 cols".
The suggestion that people should just get "better hardware" is so completely asinine, because it neglects to realize that the quality of hardware might not be the problem. For example, instead of having a single very large monitor, I use three somewhat smaller monitors because that enables other productive workflows.
A single line of code should be written to file as a single line - no matter how long. However, the editor you are using should be able to gracefully word wrap it depending on your settings.
Most editors word wrap based on window size or some other hard setting. They should be able to wrap gracefully at a logical point in the code e.g. at a comparison operator or a dot in a function chain. Wrapped lines could be tabbed or visually flagged to let you know.
In other words there should not be am ideal line length for code, but instead editors should be able to adapt to make life easier for developers.
Look at word processor documents, imagine how much of a nightmare it would be if such documents had a hard limit of characters per line.
This is so clearly right, how can it not yet exist?
‘Just’ dynamic virtual pretty print per personal lang style prefs.
That’s why for function calls passing multiple arguments where each argument may be non trivial, it’s a good idea to put each argument on its own line.
1 /* A function that does something */
2.1 int do_something(int foo,
2.2 int bar,
2.3 int baz)
2.4 {
2.5 return foo + bar + bam;
2.6 }
Which would condense to: 1 /* A function that does something */
2 int do_something(int foo, int bar, int baz) { return foo + bar + bam; }
When you try to compile this, the compiler will complain about line 2, which you know from your editor's line numbering encompasses lines 2.1 through 2.6. As an alternate strategy, you could use column numbers instead of sequential sub-lines, like so: 1 /* A function that does something */
2.0 int do_something(int foo,
2.26 int bar,
2.35 int baz)
2.44 {
2.46 return foo + bar + bam;
2.70 }
And then, if the compiler reports a column number or offset into the line, you'll immediately know "well the compiler's complaining about line 2 column 65, which is between 2.46 and 2.70... golly gee willikers, I fat-fingered the third addend in the return statement!".You could get even more abstract than this, with "line numbers" instead being local to a given scope, and the compiler reporting erroneous line numbers relative to said scope. If the compiler tells you that the syntax error is in the first (in this case also last) statement in the function do_something, then it should be apparent where to look.
That said, I don't know of many text editors (outside of notepad, and even that's gotten better lately) which don't offer options about how to (or not to) wrap text.
So perhaps this is the test of AI, when it formats my code the way I want it all the time without making a mistake.
I think the pragmatic solution is an opinionated linter that can be broken.
120 is also what I've settled on & am used to. But I'd be equally OK, and adjust fine, with anything from 100-120.
And when you need to change, say, the second parameter, you will see that the same call is made n times, and not forget one in the process.
He said, wow, Windows is really nice! :)
This should be standard in Windows IMO. It has absolutely transformed how I work and noticeably increased my productivity.
I arrange windows to provide the information I need. That's usually a strip on the left to show the mailbox pane of my mail window, a strip below that for slack channels, and a finder window on a scratch directory.
To the right are my work windows.
Window snapping makes that impossible, about the only thing you can do is pretend you're using a tiling WM and cmd-tab any time you need to see anything, or waste an inflexible chunk of screen on it.
I also find diffs that involve changes to shorter lines easier to read compared to ones with longer lines.
I wonder what he now thinks about line length in email and git commit messages (excluding things like logs, error messages, etc)?
Personally, I like 80 character lines. If I need more than 80 characters in a line, I treat it as a code smell.
That statement follows along the same line of thought that many people that want 80 char lines have. That it's better because "it's optimal". I have yet to see any significant study actually showing this to be true for the case of something like code.
Personally, I like longer lines where they make sense, and shorter lines where they make sense. But overall, I like a line configuration that lets me understand as much as possible with one screen of lines. That's the same reason I prefer short functions, because I can understand more in the same screen space from a single function call (by the name) than I can if the same code is inline.
I don't personally feel that the indentation most programming languages employ have any effect at all on my reading, unless possibly it's too narrow as code is partially read as a graphical construct. Hence limiting the length of the entire line to an equal width seems unnecessarily restrictive.
Contextually local variable names which go far above 10 characters and contextually local function names which go far above 20 characters are almost always misnamed. Nobody should struggle to fit at least within about 100 characters when they're focusing their code on clarity and simplicity.
Obviously this doesn't mean that you should rename your buf_size variable to bsz or s. But you buf_size variable in a function called read_line shouldn't need to be called line_buffer_size and if there's only one buffer should potentially just be called size.
Then there's people in this post claiming that research relating to readability of text don't apply to code because people don't read whole lines. I only have to wonder if these people have ever read code they didn't write on that same day or from a codebase they're already very familiar with. I read a lot of code, it's part of my job, I need to read the whole lines so I can verify that there's nothing horribly wrong. It makes it incredibly difficult to read expressions when they can't fit within my visual field.
Yes, hard-wrapping code is not great, it should be avoided and only done with a good bit of experience, insight and awareness of how it's going to affect the code. Regularly making your code 150 lines long because your variables are repeatedly telling me information I could have just gathered from looking two lines up and because your function names are descriptions of the behaviour of the code they contain isn't a great look either.
Although I still think that my least readable experience was having to read and work with code which used a 2 space indent (and an editor which wouldn't let me fix this in any way) which regularly went 10 levels deep and 100s of lines long.
That said, the best argument on line length is “the magic number 7, plus or minus 2”, our limits on short term memory. I like to be able to comprehend a line of code (or of text) in one glance, which seems to me to be about 65 characters, ignoring leading indentation; that might well be less than about 10 tokens. With wide tabs, that might well hit something around 90 characters, perhaps.
IMHO, it's not the line length that matters, but the number of tokens per line.
By the way, I like to work on laptops. If anyone knows where I can get a laptop with a 43" screen, please let me know.
I'm barely in my mid 30s and the average font size has been steadily creeping, maybe 1.5 pts per 5 years.
I could tolerate 132 column files today, but by the time I'm 50 there is no way this will work, regardless of screen size
We should be focusing instead on the contextual and cognitive pros and cons of various line lengths.
There's no more room on a 43" 3840 x 2160 monitor than there is on a 32" 3840 x 2160...
The refresh rate might be slower, so of you get annoyed by a 30Hz refresh rate, you'll want to make sure the TV does 60Hz.
Nowadays I'm guessing anything but the cheapest models can do it for any given resolution, but some diligence is probably in order as TV specs are not as uniform and reliable as monitor specs.
Sadly, they don't make them with anything under 1.25.
To be fair, so has the monitor resolution and its density. I'm looking at HN, and imagine, ten years ago, I was using 1280x1024 then, this very font would've physically been a much bigger picture. So in effect, the font-size increase may only counter-measuring the resolution increase...
On most operating systems, this is supposed to be almost irrelevant since they use a "virtual" resolution and DPI that gets used to render apps at a reasonable size across displays.
But I hated the 42" 4K I tried and returned it. The problem was the edges are just too far away. If I use them I end up with the same kind of neck strain I would get with a multi-monitor setup. So I only used kind of the middle section of the screen anyway. And at 42" 4K the physical pixels are just too big - everything is fuzzy.
32" 4K is the sweet spot for me. Maybe when there's a reasonably priced 42" 8K curved display I'll give it a go.
My work setup is 2x24" monitors, and I really prefer 2 small ones instead of a bigger one. I can orient them so that all pixels are approximately at the same distance to my eyes.
Is the kernel getting impossible to compile on anything less than a monster $2500 gaming rig? Too bad. Stop being poor or from a poor country.
Does the code require a $1000 monitor to be readable? Same.
Do you need a larger size font because of age? Well pop your Benjamin Button polls coz Linus Torvalds dont care.
I'm a similar age, and my font size has been decreasing steadily. As monitors get better pixel density, text is readable at smaller size. The ereader app I use on my 5.6" phone screen shows 38 lines of text (and approx 45 characters wide) plus blank margins.
The more interesting question is "what would be a good default line length in 2020?"
I vote for 120 columns.
Next natural values are 106 (for 9px fonts) and 95 (for 10px fonts).
My work machine is a macbook pro 13", I rarely have a second monitor (and when I do, I tend to have my browser on it). I get 2 panes of just under 90 chars side-to-side in VSCode, with a normal-smallish font.
Am I in such a minority?
I always feel like when people advocate 'no 80 column terminals period' they're arguing from the standpoint of having never had to use anything smaller than an ultrawide resolution display or three+ monitors. Larger lines are almost unreadable on my screen and any sort of word wrapping only makes it worse, so often I'm stuck with one file open at a time slowly jumping between files.
80-column terminals as someone else brought up is an accessibility issue.
I would increase the limit if I can fit more though and I don't mind accommodating others who prefer a higher limit.
Its time for more development tools to be built with individual developer in mind, adaptable to their workflow and needs. See for example https://old.reddit.com/r/javascript/comments/c8drjo/nobody_t...
And if I'm a coder on your team, please pick the optimal display width using a 12 inch 1080p laptop screen. Also, pretend that your vision isn't 20/20. Thank you.
Bottom line, 80 columns isn't unreasonable.
Suppose I'm at 80 characters, and everyone agrees this is a reasonable line. Then suppose I refactor a variable that was 3 characters and its now 12 characters, and everyone agrees this is a better variable name. Now my 80 character line is 89, and it's suddenly unreadable?
No, that's still readable, it's just longer.
Personally if I see a long line, I try to shorten it, but I'm okay to leave it long if I think longer is better.
Like Linus, I find 80 columns too narrow a limitation (and I got started on a 40x25 system, not even 80x25), but it would seem useful to me to standardize on some sensible maximum width, e.g. 100 or 120 columns.
In some cases, unreasonable gymnastics needs to be done to get 80 character lines, turning good variable and function names into shorter worse ones or adding functions just to hide characters.
I often do it too to improve readability, but it doesn't always actually improve readability. Sometimes it takes something which makes logical sense to have in one line and arbitrarily breaks it up in awkward spots over several lines.
If you squish code into 80 characters wide, you lose vertical density, making a set of actions more difficult to understand by separating steps.
Applying a short limit to solve the problem of any single line becoming overly-complex will have other consequences. Most obviously, it's going to push some developers into bad habits re: naming things, where variable names that have more meaning than a counter become single letters.
Four years ago I wrote a stackoverflow question about this and included some pictures:
https://stackoverflow.com/questions/31414385/is-it-possible-...
I got a link to a dusty now-9-year-old issue in Jetbrains' tracker:
Modern languages come with excellent auto-formatters which can make the code look nice at just about any line length. What we need to do is integrate the auto-formatting into the editor (likely via a language-server) so that it can adjust to the width of the editor dynamically instead of running it directly on the files at some width that's forced to be the same for every user of the codebase in every setting.
(I think this is a terrible idea, but also got me thinking if there's something interesting there)
That said, I try and practice what I preach and let my coworkers who are into wide lines (120, woof) have ‘em. I just run a formatter after I check code out, ez. Everyone should do this, online diffs should default auto format to 80 cols (but configurable), and we should put this debate to rest.
The question is not precisely “how wide can I display code”. The question is “how wide is a side by side diff?” That is the worst case scenario for code reading, and it is the one where the worst classes of errors can slip in (one where neither author actually wrote the bug).
Linus answers this indirectly: you can easily diff 100 characters on a monitor smaller than his. What he says instead sounds like an invitation to suggest 200 column source code, which most definitely is a problem to diff.
Plus I find that most of the time I just use the default patch view, not the side by side one when doing review.
https://dave.autonoma.ca/blog/2019/06/06/web-of-knowledge/
In his Elements of Typographic Style, Robert Bringhurst suggests that 66 characters per line, including spaces, for single-column pages is optimal:
https://dave.autonoma.ca/blog/2020/04/11/interior-book-desig...
What studies have reviewed code quality versus line length? Or eye fatigue versus line length? Or comprehension versus line length? Are their any studies that attempt to approach optimal line length empirically?
My preference is to indent 2 spaces rather than 4, which allows a lot of code to fit within 80 columns. When and why did 4 spaces became the norm?
- Linus Torvolds
[1] https://github.com/torvalds/linux/pull/17#issuecomment-56611...
peaks and valleys between functions and such are a huge aid visually -- line wrapping makes visualization of source code harder for myself, personally.
If you use vim, look into the "breakindent" option.
If you use Emacs, you can use the "adaptive-wrap" package with a configuration like this:
;; Indentation of softwraped code
(use-package adaptive-wrap
:ensure t
:init (defun my-activate-adaptive-wrap-prefix-mode ()
"Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
(adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
(add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode))I agree with Linus in some ways, but I think he's also repping a broad-front executive-style decision rather than a really nuanced one. And the details can really impact the preference in a case like this.
def f(
a,
b,
c,
d
):The width of a github code window is about 120 characters. That's suggested max line width because horizontally scrolling diffs during a code review is terrible. It is rare that we have any lines close to that long though.
125 characters per line is the real de facto coding standard for maximum line length these days, because this is the maximum number of characters that you can see in the GitHub diff view. This used to be 119 characters, but the page layout changed.
I just updated my editor to show rulers at 100, 120, 125.
I may be imaging this, I dunno.
I have to agree going wider than 120 makes things harder to read. 80, no, there is no way I'm going to voluntarily follow that standard - I will have to be forced into it, and I won't like it.
That said, I do 4 space indents and 100 columns, not either/or. 2 space and 100 is an invitation to excessive nesting over decomposition. If you insist on 2 spaces then I’m afraid I’m going to insist on 80 columns (and that you finally get off your ass and learn how to code).
At least at work, I feel like my 80 column terminal is probably the only “reasonable” app as far as layout and readability go.
And I really don't want to spend brain power thinking about where to wrap things. I was glad that word processors made it so I didn't have to think about carriage returns after about 1981 (yes I learned to type on a mechanical typewriter), and glad I stopped having to think about it in source code around 2010.
[0] https://twitter.com/rob_pike/status/563801489190043648?s=21
Coming from the perspective of that era I never understood the obsession with 80 characters per line.
I can honestly say that I have never limited my code through such artifice, ever.
I can give examples of code where artificially breaking things into 80 characters makes an absolute mess out of things. Complex table-driven state machine lookup tables and FPGA I/O definitions come to mind, among others.
Keeping lines short also helps when pasting code to instant messengers or reading side-by-side git diffs.
80 seems good to me.
Description should be autowrapped to each individual's preference, some have larger screens, some smaller, some need larger fonts, some smaller. The message shouldn't have a pedantic upper limit either. Fscking autowrap it if you're using a VT-100.
The only things that changed are developers and their developer setups. We got better, wider monitors and we got used to using longer variable and function names.
80 characters is an arbitrary constraints that requires me as a developer to think how I am structuring my code. It also makes it easier for me to read the code as 60 characters is about perfect column width for readability.
Don’t use wrapping, it destroys the layout (of a log etc).
Just scroll to see the rest of the line! You scroll down to see any lines that aren’t on screen, why would (occasionally) scrolling right be worse? Readability is some times worse with wrapping.
If you want to answer “but my terminal can only trim or wrap, not scroll!” then perhaps that’s a relic just like the 80 wide display?
Do what makes the most sense for readability, but often lines significantly over 80 characters are more readable as two lines.
I typically work with multiple horizontal splits open. That's part of why I prefer 80 characters. However, I really do feel that a soft break at about 80 is good for readability, and certainly easier with larger fonts.
There's still a lot of issues that need to be solved, but I'm hopeful all the pieces will come together in a relatively short amount of time.
Everytime someone tries to argue for it I want to suggest we swap their Mac for a Commodore 64...
Interestingly, this was basically (ha) an editor limitation, not a language one. You could use 2-letter abbreviations for the language's reserved words to cram more code into the same space. The programs were stored (IIRC) in tokenized form.
:-)
That is what he says
[1] https://llvm.org/docs/CodingStandards.html#source-code-width
I've never measured it, and my observation is very likely biased (as I've mostly worked with C++), but I've found 80 columns in big C++ projects often very limiting. Maybe less often now, after people are most accepting to new features; e.g type inference `auto` over `MyNameSpace::BlahContainer::const_iterator iter`.