展示HN:我写了一本书:《代码的元素》
嗨,HN!<p>我写了一本关于编程的书,名为《代码的元素》。我将整本书在线发布在这里:<a href="https://elementsofcode.io/" rel="nofollow">https://elementsofcode.io/</a><p>在指导(通常是新手)程序员时,我注意到他们的代码中存在一些常见错误,这些错误似乎占据了代码复杂性的约80%。我找不到一本简明的指南来修正这些错误,于是决定自己写一本。<p>书名向斯特朗克和怀特的《风格的要素》致敬,这本书是关于如何用散文有效沟通的经典指南。那本指南相当实用,而我希望在《代码的元素》中也能保持这种关注。因此,《代码的元素》尽量不关注抽象概念,而是针对具体的实现。它避免讨论软件设计,而更专注于代码构建的细节。当然,设计与实现、战略与战术从来不是完全分开的。在必要时,会包含一些抽象概念以提供背景。<p>本书的主要关注点是沟通:我们如何编写其他程序员能够理解的代码?我们如何减少他们理解所需的时间?<p>我将这本书免费在线发布,因为我更希望它能够被人们获取和阅读,而不是为了赚取一些钱(当然,购买也非常欢迎!)。我真诚希望读者能觉得它有帮助,并为他们提供新的工具和新的思维方式来编写代码。<p>我很想听听你们的想法,我会尽量回复问题。谢谢!
查看原文
Hey HN!<p>I wrote a book on programming called The Elements of Code. I put the entire book online here: <a href="https://elementsofcode.io/" rel="nofollow">https://elementsofcode.io/</a><p>When mentoring (usually new) programmers, I noticed there were a few common mistakes that seemed to account for about 80% of the complexity in their code. I couldn’t find a concise guide to fixing those mistakes, so I decided to write one.<p>The title is an homage to The Elements of Style by Strunk and White, which is the classic guide for communicating well using prose. That guide is quite tactical in nature, and I wanted to parallel its focus in The Elements of Code. As a result, TEOC tries not to focus on abstract concepts, and instead targets concrete implementation. It avoids discussing software design in favor of the minutiae of code construction. Of course, the design and implementation, the strategy and the tactics, are never entirely separate. When necessary, some abstract concepts are included to help provide context.<p>The primary focus of the book is on communication: how can we write code that other programmers will be able to understand? How can we reduce the time it takes them to understand?<p>I put it all online for free because I would rather the book be accessible and read than make a few bucks (though purchases are certainly welcome!). My sincere hope is that readers find it helpful, and it gives them new tools and a new way to think about writing code.<p>I’m interested to hear what you think, and I’ll try to respond to questions. Thanks!