TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

GNU Coding Standards: Writing Robust Programs

120 pointsby mpsqalmost 4 years ago

8 comments

kstenerudalmost 4 years ago
&gt; In error checks that detect “impossible” conditions, just abort. There is usually no point in printing any message. These checks indicate the existence of bugs. Whoever wants to fix the bugs will have to read the source code and run a debugger. So explain the problem with comments in the source.<p>But then the person <i>RUNNING</i> the program will only see this:<p><pre><code> Abort trap: 6 </code></pre> And that&#x27;s all the info you&#x27;ll get from their bug report.<p>So please ignore this directive and print a descriptive message always, complete with file and line, and the values that led to the impossible situation. Then you can get helpful bug reports like:<p><pre><code> BUG: flush.c:51: buff_offset (65535) must not be greater than 20! Abort trap: 6</code></pre>
评论 #27475184 未加载
pjmlpalmost 4 years ago
&gt; When you want to use a language that gets compiled and runs at high speed, the best language to use is C. C++ is ok too, but please don’t make heavy use of templates. So is Java, if you compile it.<p>Back in the early days, this sentence was more like <i>&quot;When you want to use a language that gets compiled and runs at high speed, the best language to use is C.&quot;</i>.<p>So we switched from a path where all major desktop environments (OS&#x2F;2, Mac, Windows, UNIX) were adopting C++ to a surge in C programming, as FOSS adoption started to gain steam.<p>So here we are now, about 30 years later, trying to fix the security inconveniences caused by this manifesto.
评论 #27471746 未加载
评论 #27471959 未加载
评论 #27474131 未加载
评论 #27472516 未加载
评论 #27472301 未加载
评论 #27473762 未加载
评论 #27471692 未加载
bigbillheckalmost 4 years ago
I see that they still say:<p>&gt;&gt;&gt; Please don’t use “win” as an abbreviation for Microsoft Windows in GNU software or documentation. In hacker terminology, calling something a “win” is a form of praise. You’re free to praise Microsoft Windows on your own if you want, but please don’t do so in GNU packages. Please write “Windows” in full, or abbreviate it to “w.”<p>But they have removed some other guidance:<p>&gt;&gt;&gt; Instead of abbreviating “Windows” to “un”, you can write it in full or abbreviate it to “woe” or “w”.
评论 #27475382 未加载
评论 #27473562 未加载
评论 #27472533 未加载
jjicealmost 4 years ago
Always interesting to see standards across different groups. The kernel is also very interesting, being very strict and having reasoning that not all may agree with, but has proved to work well.<p>I think C is a beast for standard in general due to it&#x27;s rogue history. Now when a language like Rust or Go is created, standards are released with the code via formatting tools that enforce consistency (which I&#x27;m all for).<p>The amount of time I&#x27;ve seen C code with inconsistencies within a single file (naming, spacing, you name it) from fellow students back when I was in college was insane.<p>Enforced code style standards are great, even if I don&#x27;t agree with them. Go&#x27;s public vs private distinction is a good example. I really am not a huge fan of the pascal vs camel case to denote private and public (it&#x27;s grown on me a bit, but still not a fan), but I know their code is going to be reasonable (in looks) because Go is very picky about how the code looks.
asicspalmost 4 years ago
&gt;<i>In most Unix utilities, “long lines are silently truncated”. This is not acceptable in a GNU utility.</i><p>Would be interested to know examples for this.
评论 #27460035 未加载
评论 #27471671 未加载
评论 #27471670 未加载
评论 #27476160 未加载
sigzeroalmost 4 years ago
I hate that formatting style personally.
评论 #27472752 未加载
评论 #27473946 未加载
评论 #27477043 未加载
musicalealmost 4 years ago
How about &quot;always use gcc&#x2F;g++ in memory-safe compilation mode?&quot;<p>I&#x27;d like to be able to type something like:<p><pre><code> gcc -march=x86-64-safe my_buggy_server.c </code></pre> Come to think of it, that should probably be the default.
abakusalmost 4 years ago
I find the coding standard too long to be taken seriously.