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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Notes on Programming in C - Rob Pike, February 21, 1989

139 点作者 AbyCodes超过 13 年前

8 条评论

avar超过 13 年前
One thing I've changed about my style in the last few years is to almost never comment my code, but to instead write long and detailed Git commit messages explaining the how's and why of that code at the time that I write it.<p>That means that over time I effectively have comments for every line of code in the program, but it's associated metadata instead of being embedded inline, which means that the comments never go out of date, and their history is accurately tracked in version control.
评论 #3333848 未加载
评论 #3334921 未加载
评论 #3334230 未加载
评论 #3334314 未加载
评论 #3335772 未加载
评论 #3334301 未加载
jbellis超过 13 年前
Many of these are elaborated on in the more recent (1999) "The Practice of Programming." Excellent book. <a href="http://www.amazon.com/Practice-Programming-Brian-W-Kernighan/dp/020161586X" rel="nofollow">http://www.amazon.com/Practice-Programming-Brian-W-Kernighan...</a>
nitrogen超过 13 年前
The one point that is notably less relevant today is the last section regarding include files. Gcc has a special case for a header file that is entirely wrapped in an #ifndef (<a href="http://gcc.gnu.org/onlinedocs/cpp/Once_002dOnly-Headers.html#Once_002dOnly-Headers" rel="nofollow">http://gcc.gnu.org/onlinedocs/cpp/Once_002dOnly-Headers.html...</a>).
评论 #3333725 未加载
评论 #3333324 未加载
评论 #3333636 未加载
zmj超过 13 年前
These style guidelines correspond exactly to idiomatic Go. I'm impressed how well Pike executed on his philosophy.
theorique超过 13 年前
<i>Pointers are sharp tools, and like any such tool, used well they can be delightfully productive, but used badly they can do great damage</i><p>Nice physical metaphor. Pointers are ... pointy.
huskyr超过 13 年前
Even though this is over 20 years old, many comments are still very valid. I especially like the section about short variable names and functions.
评论 #3334062 未加载
halayli超过 13 年前
Those notes found their way to 'The Practice of Programming' book.<p>I highly recommend it.
falcolas超过 13 年前
Some absolutely fascinating points. However, I must admit that the portion on link pointers was, frankly, damned frightening as someone who could possibly have to come back and figure out what's really going on.<p>I'm reminded of Perl when I look at that link pointer code. It's succinct, easy to write, works great most of the time, and nearly impossible to go back and decode later. You simply require too much context to find the one place where you stepped beyond the array and into no-man's land.<p>I love pointers; I think that like other sharp tools, they have their uses. However, like other sharp tools, they require training and attention to use properly. Lots of people lose fingers to saws every year; how many brain cells have you lost to debugging pointer mistakes?
评论 #3334975 未加载