- Published on
Fuck 80 Chars Limit -- It is 2021 now
- Authors
- Name
- ttyS3
关于限制代码最大列宽:
限制在 80 个字符合适吗?
我的观点是: 都 TM 2021 年了, 80个锤子,直接来个 150 或 160 还差不多。
Linus 的观点貌似跟我一样哈?
In case of the Linux kernel, that’s of course Linus Torvalds, who has recently shaken up the community with a mailing list response declaring an overly common, often even unwritten rule of code formatting as essentially obsolete: the 80-character line limitation. Considering the notoriety of his rants and crudeness, his response, which was initiated by a line break change in the submitted patch, seems downright diplomatic this time.
Linus’ reasoning against a continuing enforcement of 80-char line limits is primarly the fact that screens are simply big enough today to comfortably fit longer lines, even with multiple terminals (or windows) next to each other. As he puts it, the only reason to stick to the limitation is using an actual VT100, which won’t serve much use in kernel development anyway.
via https://hackaday.com/2020/06/18/ask-hackaday-are-80-characters-per-line-still-reasonable-in-2020/
https://lkml.org/lkml/2020/5/28/1237
From Linus Torvalds <>
Date Thu, 28 May 2020 11:43:13 -0700
Subject Re: [PATCH 09/14] fs: don't change the address limit for ->write_iter in __kernel_write
share 0
On Wed, May 27, 2020 at 10:41 PM Christoph Hellwig <hch@lst.de> wrote:
>
> -ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos)
> +ssize_t __kernel_write(struct file *file, const void *buf, size_t count,
> + loff_t *pos)
Please don't do these kinds of pointless whitespace changes.
If you have an actual 80x25 vt100 sitting in a corner, it's not really
conducive to kernel development any more.
Yes, yes, we'd like to have shorter lines for new code, but no, don't
do silly line breaks that just makes old code look and grep worse.
Linus
https://lkml.org/lkml/2020/5/29/1038
From Linus Torvalds <>
Date Fri, 29 May 2020 12:19:02 -0700
Subject Re: clean up kernel_{read,write} & friends v2
share 4k
On Fri, May 29, 2020 at 6:08 AM David Laight <David.Laight@aculab.com> wrote:
>
> A wide monitor is for looking at lots of files.
Not necessarily.
Excessive line breaks are BAD. They cause real and every-day problems.
They cause problems for things like "grep" both in the patterns and in the output, since grep (and a lot of other very basic unix utilities) is fundamentally line-based.
So the fact is, many of us have long long since skipped the whole "80-column terminal" model, for the same reason that we have many more lines than 25 lines visible at a time.
And honestly, I don't want to see patches that make the kernel reading experience worse for me and likely for the vast majority of people, based on the argument that some odd people have small terminal windows.
If you or Christoph have 80 character lines, you'll get possibly ugly wrapped output. Tough. That's your choice. Your hardware limitations shouldn't be a pain for the rest of us.
Longer lines are fundamentally useful. My monitor is not only a lot wider than it is tall, my fonts are universally narrower than they are tall. Long lines are natural.
When I tile my terminal windows on my display, I can have 6 terminals visible at one time, and that's because I have them three wide. And I could still fit 80% of a fourth one side-by-side.
And guess what? That's with my default "100x50" terminal window (go to your gnome terminal settings, you'll find that the 80x25 thing is just an initial default that you can change), not with some 80x25 one. And that's with a font that has anti-aliasing and isn't some pixelated mess.
And most of my terminals actually end up being dragged wider and taller than that. I checked, and my main one is 142x76 characters right now, because it turns out that wider (and taller) terminals are useful not just for source code.
Have you looked at "ps ax" output lately? Or used "top"? Or done "git diff --stat" or any number of things where it turns out that 80x25 is really really limiting, and is simply NO LONGER RELEVANT to most of us.
So no. I do not care about somebody with a 80x25 terminal window getting line wrapping.
For exactly the same reason I find it completely irrelevant if somebody says that their kernel compile takes 10 hours because they are doing kernel development on a Raspberry PI with 4GB of RAM.
People with restrictive hardware shouldn't make it more inconvenient for people who have better resources. Yes, we'll accommodate things to within reasonable limits. But no, 80-column terminals in 2020 isn't "reasonable" any more as far as I'm concerned. People commonly used 132-column terminals even back in the 80's, for chrissake, don't try to make 80 columns some immovable standard.
If you choose to use a 80-column terminal, you can live with the line wrapping. It's just that simple.
And longer lines are simply useful. Part of that is that we aren't programming in the 80's any more, and our source code is fundamentally wider as a result.
Yes, local iteration variables are still called 'i', because more context just isn't helpful for some anonymous counter. Being concise is still a good thing, and overly verbose names are not inherently better.
But still - it's entirely reasonable to have variable names that are 10-15 characters and it makes the code more legible. Writing things out instead of using abbreviations etc.
And yes, we do use wide tabs, because that makes indentation something you can visually see in the structure at a glance and on a whole-function basis, rather than something you have to try to visually "line up" things for or count spaces.
So we have lots of fairly fundamental issues that fairly easily make for longer lines in many circumstances.
And yes, we do line breaks at some point. But there really isn't any reason to make that point be 80 columns any more.
------------ Linus