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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Torvalds: Standards need to be questioned

223 点作者 l1k将近 7 年前

20 条评论

tptacek将近 7 年前
He&#x27;s probably right, but he expresses his ideas so poorly that he turns straightforward points into drama, I think intentionally. He doesn&#x27;t just not give a shit about standards (probably healthy), but also what any of his audience thinks about his ideas (probably not so much).<p>At this point, his flailing supposed anger is really just schtick. He deploys it so casually you just assume it isn&#x27;t serious. Ironically, he could convey his contempt for standards, or for people who adhere to them slavishly, far more effectively if he simply wrote in a civil tone, rather than continuing to try to affect his Andrew Dice Clay of Programming persona.
评论 #17242643 未加载
评论 #17242930 未加载
评论 #17242619 未加载
评论 #17243253 未加载
评论 #17242533 未加载
评论 #17242540 未加载
评论 #17242644 未加载
评论 #17243408 未加载
评论 #17242514 未加载
评论 #17244323 未加载
评论 #17243426 未加载
评论 #17262846 未加载
评论 #17242538 未加载
pavanky将近 7 年前
Before anyone flips out, he actually merged the code: <a href="https:&#x2F;&#x2F;lkml.org&#x2F;lkml&#x2F;2018&#x2F;6&#x2F;5&#x2F;774" rel="nofollow">https:&#x2F;&#x2F;lkml.org&#x2F;lkml&#x2F;2018&#x2F;6&#x2F;5&#x2F;774</a><p><pre><code> Side note: I&#x27;ve merged it, and it&#x27;s going through my build tests, so it&#x27;s really not that I hate the code. But I really find that kind of one-sided rationale that ignores reality unacceptable. And I find it dangerous, because it *sounds* so &quot;obviously correct&quot; to people who don&#x27;t know any better. If you don&#x27;t know that gcc explicitly says that you should use unions to do type punning to avoid aliasing issues, you might believe that union type punning is a bad thing from that commit message. So it&#x27;s dangerously misleading, because lots of people have a dangerous reverence for paper over reality. In programming, &quot;Appeal to Standards&quot; should be considered a potential logical fallacy. Standards have their place, but they definitely have their caveats too.</code></pre>
评论 #17242835 未加载
评论 #17245105 未加载
dragontamer将近 7 年前
I find it ironic in that C++ has the correct solution to this problem. If you need type-pruning, use reinterpret_cast&lt;foo&gt;(bar). Done and done. Ironic, because Linus&#x27;s weapon of choice (C... or more specifically, GCC&#x27;s particular implementation of C) would require far more expertise to use correctly.<p>Lets break it down.<p>In C, type-punning is NOT part of the language. Its technically &quot;undefined behavior&quot;. There&#x27;s an expectation that when you do:<p><pre><code> short foo[2] = {1, 2} ; *(int*)foo = 0x12345678; assert(foo[0] == 0x5678 &amp;&amp; foo[1] == 0x1234); </code></pre> A little-endian machine will pass this assert. But this isn&#x27;t guaranteed by the C standard! This is &quot;undefined behavior&quot;. The C-standard allows a C compiler to assume that foo[0] and foo[1] are still == to 1 and 2 respectively. Which would cause the assert to fail. In GCC -O2 or -O3, this may happen, depending on how registers get mapped to the variables. (The canonical memory location changes, but should registers be updated when optimizations are enabled??)<p>When an optimizer can assume, and when it can&#x27;t assume, &quot;aliasing&quot; is very much an undefined behavior within the C language.<p>-------------<p>In effect, Linus knows GCC inside and out. GCC guarantees that unions will ALWAYS work for this aliasing problem. But this requires knowledge above and beyond the C Standard.<p>Linus may be &quot;hating&quot; and &quot;criticizing&quot; the standard in this case. And I guess there&#x27;s certainly a gap. But the general expectation that everyone knows the intricacies of GCC to properly understand the kernel code is misplaced IMO, and goes back to &quot;Angry Linus yells at random dev unnecessarily&quot; territory for me.<p>And instead of simply explaining this VERY simple fact (although super-obscure) that GCC makes unions safe against aliasing issues at the compiler level... Linus yells at the dev. Not fair IMO.
评论 #17242679 未加载
评论 #17242779 未加载
评论 #17242583 未加载
评论 #17242553 未加载
评论 #17243050 未加载
评论 #17242841 未加载
评论 #17242569 未加载
评论 #17242708 未加载
simonbyrne将近 7 年前
Linus has long railed against the aspects of the C standard, and how they&#x27;re been interpreted by compiler writers [0].<p>I&#x27;m not much of a C programmer, but the C aliasing rules are incredibly confusing, and seem to be interpreted differently by GCC and Clang. e.g. GCC allows type punning via unions[1], but Clang does not [2].<p>[0] <a href="https:&#x2F;&#x2F;www.cl.cam.ac.uk&#x2F;~srk31&#x2F;research&#x2F;papers&#x2F;kell17some-preprint.pdf" rel="nofollow">https:&#x2F;&#x2F;www.cl.cam.ac.uk&#x2F;~srk31&#x2F;research&#x2F;papers&#x2F;kell17some-p...</a><p>[1] <a href="https:&#x2F;&#x2F;gcc.gnu.org&#x2F;onlinedocs&#x2F;gcc&#x2F;Optimize-Options.html#Type-punning" rel="nofollow">https:&#x2F;&#x2F;gcc.gnu.org&#x2F;onlinedocs&#x2F;gcc&#x2F;Optimize-Options.html#Typ...</a><p>[2] <a href="https:&#x2F;&#x2F;bugs.llvm.org&#x2F;show_bug.cgi?id=31928" rel="nofollow">https:&#x2F;&#x2F;bugs.llvm.org&#x2F;show_bug.cgi?id=31928</a>
评论 #17242817 未加载
评论 #17243238 未加载
allengeorge将近 7 年前
So much swearing to make three points:<p>1. What&#x27;s in practice conflicts with what the standard prescribes<p>2. The reason it conflicts is because the standard is misguided and everyone knows that; for reliable code-generation you have to take the approach in the kernel<p>3. He disagrees with the rationale for the change, and wants a better reason for it
评论 #17242497 未加载
评论 #17243440 未加载
评论 #17242501 未加载
评论 #17242541 未加载
评论 #17242515 未加载
camgunz将近 7 年前
Strict aliasing shouldn&#x27;t have been set as the default [1]. It was a huge mistake that instantly broke maybe all C programs everywhere. The standard also provided no guidance on how to work around the problem. `memcpy` is insufficient because it&#x27;s a copy and that&#x27;s a huge performance issue. Swapping through unions is UB. Casting about through `void * ` and `char * ` is gross, dangerous, and often runs afoul of alignment problems. It&#x27;s a mess, and it has been for 20 years. Linus is right to be pissed.<p>[1]: <a href="https:&#x2F;&#x2F;blog.regehr.org&#x2F;archives&#x2F;1307" rel="nofollow">https:&#x2F;&#x2F;blog.regehr.org&#x2F;archives&#x2F;1307</a>
评论 #17243174 未加载
评论 #17245223 未加载
评论 #17243249 未加载
评论 #17243076 未加载
devnonymous将近 7 年前
I read the comments here before I read the post and was honestly expecting a full out swear fest. Instead, I read linus being passionately expressive about something he clearly has strong opinions about... With a few swear words and over exaggerated metaphors thrown in.<p>I&#x27;m not saying that the language is not not-nice but it&#x27;s not like he was being a bully or arsehole to someone in particular nor was he being over the top abusive. The delivery shouldn&#x27;t be the take away here.
digi_owl将近 7 年前
Reading it fully and it seems to line up with Torvalds attitudes towards things like userspace facing API stability.<p>Standards are standards, reality is reality, and when the two conflict the only way to maintain long term sanity is for the standard to be amended to fit reality.<p>The alternative is seen up and down userspace, where we have piles upon piles of workarounds, and whatsnot, to deal with APIs that change and break between releases because someone suddenly decided to re-read a standard spec like the devil reads the bible.
twoodfin将近 7 年前
And he committed the patch anyway...<p><a href="https:&#x2F;&#x2F;lkml.org&#x2F;lkml&#x2F;2018&#x2F;6&#x2F;5&#x2F;774" rel="nofollow">https:&#x2F;&#x2F;lkml.org&#x2F;lkml&#x2F;2018&#x2F;6&#x2F;5&#x2F;774</a>
评论 #17242551 未加载
评论 #17242579 未加载
infogulch将近 7 年前
Torvalds just doesn&#x27;t give a shit about appeal to authority arguments.
评论 #17242453 未加载
评论 #17243855 未加载
AceyMan将近 7 年前
Every time I&#x27;ve gotten sucked into these &lt;cough&gt; notable LKML messages from Linus I&#x27;m not taken aback in the least.<p>To my ear, his language comes across as that of a drill sergeant: intentionally loud, pejorative, and foul for reasons of effectiveness, in addition to reinforcing the hierarchy he sits atop (as do the tirades of any prototypical drill sergeant).<p>My 0,02$.<p>NB: my parent cussed like a sailor, certainly influencing my PoV.
chomp将近 7 年前
Commit in question: <a href="https:&#x2F;&#x2F;git.kernel.org&#x2F;pub&#x2F;scm&#x2F;linux&#x2F;kernel&#x2F;git&#x2F;rafael&#x2F;linux-pm.git&#x2F;commit&#x2F;?h=dp-4.18-rc1&amp;id=63dcc7090137a893322432e156d66be3ce104615" rel="nofollow">https:&#x2F;&#x2F;git.kernel.org&#x2F;pub&#x2F;scm&#x2F;linux&#x2F;kernel&#x2F;git&#x2F;rafael&#x2F;linux...</a>
mark-r将近 7 年前
Is there any part of the standards process that is geared to the needs of the users of the compiler? Or is it all determined by the compiler writers themselves? I&#x27;m wondering why this kind of push back is necessary.
评论 #17242603 未加载
busterarm将近 7 年前
I can&#x27;t imagine what it&#x27;s like to be in Linus&#x27; position. After all these years he still hasn&#x27;t found Linux&#x27;s own Junio Hamano to turn over maintainer-ship to.
alexandercrohde将近 7 年前
I wonder if there&#x27;s a way to put all this engineering thought into reducing&#x2F;simplifying standards and optimizing compilers so that individuals don&#x27;t need a Linus-level knowledge.<p>In my opinion, the knowledge-cost of a system is a major downside that is often ignored (probably the biggest downside of unix, vi, git).
davesque将近 7 年前
Honestly, I read a few sentences, began stumbling over the expletives, then decided I didn&#x27;t care what the issue was or what his opinion is. Though he acts like everything that isn&#x27;t done precisely as he would have done it in hindsight is &quot;utter garbage&quot;, there are probably all kinds of historical and logistical reasons that things were done a certain way and that doesn&#x27;t make the people involved &quot;f*cking morons.&quot; And, to save everyone the trouble, the usual refrain of &quot;he&#x27;s actually right&quot; is meaningless to me.
评论 #17243020 未加载
yedawg将近 7 年前
Roasting other developers for getting it wrong is so much worse than just saying &quot;the standard doesn&#x27;t apply here. Try this instead&quot;
thelastidiot将近 7 年前
He is so full of it. It wouldn&#x27;t hurt to say it nicely in 3 sentences.
Bromskloss将近 7 年前
I would rather that he made a standard wherein he specifies how he thinks the language should behave, and then followed that standard slavishly. One must follow _some_ standard slavishly!
jaequery将近 7 年前
there is nothing new here.