
程序风格要素
The elements of programming style
Brian W. Kernighan、P. J. Plauger · 初版 1974 年
30人推荐
69位读者提及
96次提及
为什么值得读
- 指导初学者告别意大利面条式的混乱代码
- 教人写出简洁直接且易于调试的程序
- 几小时即可读完并提供终身受用的规则
Hacker News 上怎么说
正在加载完整评论……

The elements of programming style
Brian W. Kernighan、P. J. Plauger · 初版 1974 年
正在加载完整评论……
……所谓的“面条代码”(spaghetti code)。在去上课之前,我根本分不清谁给我的建议靠谱、谁的建议坑爹。我写的代码毫无组织,烂成一锅粥。在我们课上,教材是 Kernighan 和 Plaugher 写的《The Elements Of Programming Style》。在我看来,这就是给初学者准备的“圣经”。虽然现在很稀少而且很贵,但绝对值。概括来说,它教的就是:- 用直接的方式编程,千万不要……
…called "spaghetti code." I had no idea (before the classes) who was giving me good advice and who was giving me bad advice. My code was unorganized and a total mess. In my class, our textbook was "The Elements Of Programming Style" by Kernighan and Plaugher. As far as I'm concerned, it is THE book for beginning programmers. It's rare and expensive now, but worth it. In a nutshell, it taught: - program in a direct way, do NOT…
……买了它。真的很棒,因为你花几个小时就能读完,而且能学到很多东西。我一直遵循这本书里的很多规则和指导原则。我顺便再推荐一本《On Writing Well》。剧透一下:5b. 《The Elements of Programming Style》——也就是编程版的《The Elements of Style》加上了 Brian Kernighan。要不是我自己确信写得极好,我是不会推荐的。我可不是那种人。我对自己的推荐完全负责。
…bought it. It's really good because you can read it in a few hours and learn a lot. I follow many of the rules and guidelines in this book. I'm also going to recommend On Writing Well. Spoilers. 5b. The Elements of Programming Style - The Elements of Style + Brian Kernighan. I wouldn't recommend a book that I don't trust is really well written. That just wouldn't be me. I stand behind my recommendations.
……为了啰嗦而啰嗦。如果你觉得代码简练只是为了炫技,那你根本没搞懂重点。写出晦涩难懂的代码和写出简洁地道的 idiomatic code 是两码事——参考 Kernighan 和 Plauger 的《The Elements of Programming Style》。我宁愿让 Kernighan、Ritchie、Thompson、Pike 这帮人来写我的生产环境代码,也不想让那些觉得用 C 语言指针惯用法属于大逆不道的人来写。“那种事情”早就……
…for the sake of being wordy. If you think the code is terse just to show off you are missing the point. There's a difference between writing obscure code and writing concise idiomatic code -- see "The Elements of Programming Style" by Kernighan and Plauger. I'd rather Kernighan, Ritchie, Thompson, Pike, et al. write my production code than someone who thinks C pointer idioms are a punishable offense. "That sort of thing" has been…
……写程序本身就比调试容易。所以如果你在写代码时就已经耍尽了聪明才智,那你以后还怎么 debug?”——Brian W. Kernighan。几年前我读过 Brian Kernighan 的一本书《The Elements of Programming Style》,对我来说里面有太多宝贵的建议了。在这个 Ruby、C99 满天飞的时代,这本书可能没那么应景了,但建议依然很有价值。我有时在想,去读那些文献(无数人写的各种书……
…writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?" -Brian W. Kernighan I read a book by Brian Kernighan a few years back, "The Elements of Programming Style" and for me it has so much good advice. The book may not be as relevant in the days of Ruby, C99 and the like, but valuable advice nevertheless. I wonder if reading the literature (countless books written…
……不用担心。那些单独的重构手法多多少少还挺有意思,但就像其他人说的那样,现在看来已经有点老生常谈了。每个程序员都应该读的两本书:Kernighan 和 Plauger 的《Software Tools》[1] 和《The Elements of Programming Style》[2]。附赠一本:Kernighan 和 Pike 的《The Unix Programming Environment》[3]。[1] https://www.amazon.com/Software-Tools-Pascal-Brian-Kernighan... [2] https://www.amazon.com/Elements-Programming-Style-2nd/dp/007...……
…no worries. The individual refactorings are more-or-less interesting, but as others have said, they're somewhat commonplace now. Two books that every programmer should read: Software Tools[1] and The Elements of Programming Style[2] by Kernighan and Plauger. Bonus: The Unix Programming Environment[3] by Kernighan and Pike. [1] https://www.amazon.com/Software-Tools-Pascal-Brian-Kernighan... [2] https://www.amazon.com/Elements-Programming-Style-2nd/dp/007...…
Kernighan 合著过一整套书,本本都是精品。另外三本是《Unix 编程环境》(The UNIX Programming Environment)、《软件工具》(Software Tools,包含 Ratfor 和 Pascal 两个版本)以及《编程风格的要素》(The Elements of Programming Style)。它们之所以成为经典有很多原因,其中之一就是篇幅虽短,却能带你走得极远。
There's quite a series of books co-authored by Kernighan, all excellent. Three others are The UNIX Programming Environment, Software Tools (in Ratfor and Pascal), and The Elements of Programming Style. They are classics for many reasons, including how far you get in such short books.