TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Excessive line breaks are bad

29 点作者 trias将近 5 年前

10 条评论

merricksb将近 5 年前
Big discussion about this post a few days ago:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23356607" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23356607</a>
pbw将近 5 年前
I&#x27;m confused. This page [1] claims to be the &quot;Linux kernel coding style&quot; and it says &quot;The limit on the length of lines is 80 columns and this is a strongly preferred limit&quot;. So he&#x27;s reversing that without actually updating the guide? And without setting a new limit? He implies maybe &quot;100&quot; is a good limit but maybe &quot;142&quot; is even better? Weird.<p>I know he&#x27;s primarily talking about terminal output not code, but he implies it&#x27;s for code too &quot;and our source code is fundamentally wider as a result&quot;. Seems like a very sloppy transition of a huge project to a new vague standard? I&#x27;m not impressed the clarity here.<p>[1] -<a href="https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;html&#x2F;v4.10&#x2F;process&#x2F;coding-style.html" rel="nofollow">https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;html&#x2F;v4.10&#x2F;process&#x2F;coding-style.h...</a>
评论 #23378733 未加载
评论 #23378930 未加载
iforgotpassword将近 5 年前
Fully agree. Lines should be as long as they need to be, and break where it makes sense, not because some arbitrary limit that stems from a technical decision 40+ years ago is hit.
m463将近 5 年前
I liked this comment elsewhere in the thread:<p>&quot;Tab depth use in the kernel is more or less<p><pre><code> $ git grep -Poh &#x27;^\t+(if|do|while|for|switch)\b&#x27; | \ sed -r &#x27;s&#x2F;\w+&#x2F;&#x2F;g&#x27; | \ awk &#x27;{print length($0);}&#x27; | \ sort | uniq -c | sort -rn 903993 1 339059 2 89334 3 18216 4 3282 5 605 6 148 7 36 8 4 9 1 10 </code></pre> <a href="http:&#x2F;&#x2F;lkml.iu.edu&#x2F;hypermail&#x2F;linux&#x2F;kernel&#x2F;2005.3&#x2F;06570.html" rel="nofollow">http:&#x2F;&#x2F;lkml.iu.edu&#x2F;hypermail&#x2F;linux&#x2F;kernel&#x2F;2005.3&#x2F;06570.html</a><p>I like seeing these &quot;back of the napkin&quot; sorts of code snippets revealed... this is the sort of thing that happens frequently but isn&#x27;t ever shared because of its throwaway&#x2F;ephemeral nature.<p>And also, yeah, low tab depth is way more relevant than line length as far as clean code.
saidajigumi将近 5 年前
This rant feels a bit banal, like it&#x27;s going up against a straw-man just to be ... a rant. On one hand, I can&#x27;t think of the last time a developer in an org I&#x27;ve worked with hasn&#x27;t <i>conspicuously and regularly</i> used text windows wider than 80 columns. On the other, well-written code (and prose!) also exploits <i>limiting</i> line length for clarity and readability. There&#x27;s clearly a balance, helpful rules of thumb paired with useful times to break those rules.<p>To be honest, the worst regular example I encounter, in either direction, is Markdown source with no hard line breaks. Markdown fully supports them, and trying to read paragraphs in whatever-hundred character lines is a painful exercise. Such irony, since part of the beauty of Markdown is dual readability in both source and rendered forms.
jkhdigital将近 5 年前
&gt; But still - it&#x27;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.<p>This is my main justification for ignoring any particular limit on line length when writing code, especially when I&#x27;m using libraries that have really long method names.
errantspark将近 5 年前
I like 80-ish character lines. I&#x27;m glad Linus is yelling about this though, dogmatic beliefs are the root of much evil.
greatgib将近 5 年前
I fully agree with his opinion! This deserves to be in the top of HN!
gcoda将近 5 年前
After missing some errors in long lines during code review, i feel like &lt;60 should be the target. side by side diffs are most common view for me in &#x27;github flow&#x27;
评论 #23378700 未加载
dkdk8283将近 5 年前
I’m impressed to see this from Linus. We’ve had terminals wider than 80 chars for awhile - a limit I think needs to be revisited.
评论 #23378832 未加载