HN 写作课

工程师们二十年里聊过的写作。

工程师、作家、编辑和创业者在 Hacker News 上聊了二十年“怎么写”:怎么写得清楚、怎么讲好一个故事、技术文档怎么写、小说和出版是怎么回事。这里把其中关于写作与讲故事的帖子挑出来,配上中文导读、可以直接用的写作要点和评论翻译。

从必读开始
  • 2,600+篇关于写作的 HN 讨论

Writing tips

写作锦囊

正在抽一条写作要点…

Essential

必读 30 篇

在讨论库里看全部精选

编辑精选里 HN 讨论最热的 30 篇,每篇都有中文导读和写作要点。

  1. 正在载入…

Archive

讨论库

按发帖年份分布,点柱子筛选。

排序

    About

    这些讨论是怎么挑出来的

    1. 01

      从全量里捞

      读取 Hacker News 自 2006 年以来的全部帖子,用关键词先捞出 40 分以上、可能和写作有关的约 1.1 万篇。

    2. 02

      只留真正讲写作的

      由 AI 逐条判断是否和写作、讲故事、文风、出版有实质关系,剔除“写代码”“编辑器”这类字面撞车,并分进十个类别。

    3. 03

      提炼可用的要点

      为值得读的帖子写中文导读,提炼 2-4 条可以直接用到自己写作里的要点,并精选翻译 HN 高赞评论。内容由 AI 生成,可能有误。

    技术写作与文档2020antirez.com

    编写系统软件:代码注释

    Writing system software: code comments

    阅读原文 HN 讨论
    45HN 得分
    3条评论
    4条写作要点

    导读

    这是 Redis 作者 antirez 关于系统软件中如何写代码注释的随笔:他区分了有价值的注释与噪音,也分析了“把旧代码注释掉留在原地”这类有争议的做法。对写作者来说值得一读,因为注释的取舍与一般写作相通;核心是在正文里交代意图、背景和取舍,替读者省去猜测。

    关键词 代码注释技术写作写作意图读者意识

    可以直接用的写作要点

    1. 01

      说明性文字应回答“为什么这样做、放弃了什么”,不要重复“做了什么”;后者读者自己看得见。

    2. 02

      把失败方案和走过的弯路留在文里:读者看到“这里曾经是另一种写法”,才明白现状为何如此设计。

    3. 03

      不要指望读者去翻版本历史或旧草稿,从而自行还原你的动机;背景要显式写出来。

    4. 04

      动笔时假定读者是几个月后的陌生人(甚至未来的自己),主动补上他不可能知道的上下文。

    HN 评论精选

    注释承载着版本历史传达不了的决策上下文和“此路不通”的经验,不能因为有了 Git 就一概否定。

    这根本不奇怪。一项选择的后果,远不止一小段幂等代码,并非翻翻历史就能看出“这里本可以换个写法”。很多时候,某种策略或具体实现因为依赖不断变化,走过的关键实现和死胡同本身就是教学材料:周围的代码看起来又怪又浪费,直到你看到注释说明 20 个提交前这里是什么。还有“预置提交”——功能代码写好了,依赖却没就绪就要交接给别的团队,等集成等几个月是常事;把集成放在别人因内部流程拿不到的分支里,等于断了后来者的路,而注释掉并附上说明,就给他留了可循的路径。还有多少次改动没测试就上了生产?这种事天天发生。

    Supermancho查看英文原文

    > Finally backup comments are the ones where the developer comments older versions of some code block or even a whole function, because she or he is insecure about the change that was operated in the new one. What is puzzling is that this still happens now that we have Git. It's not puzzling _at all_. The implications of choices (which aren't limited to small blocks of idempotent code) are not a matter of reading through the history and figuring out "hey right HERE it could have been done differently". There are many points where the strategy or specific implementation (due to the flux of integrations with ever-changing dependencies) have had relevant implementations and dead-ends, which serve as a teaching tool. The surrounding code often looks strange and wasteful, until you see the comment showing what USED to be there 20 commits ago. There's also the planned commit, which is one where a functional bit of code is done and a dependency isn't ready before handoff to another team or developer. Ever had to wait for months for an integration? It happens all the time. Putting a specific integration in another branch you have access to, that may not be accessible for internal procedure reasons to someone else, leaves a developer with an obvious path forward to salvage the work - put it in the code commented out with a little teaching. How many times do you make a change and it goes to prod without tests? Happens all the time. Those kinds of places don't always have typical branch hygiene. You can label these different kinds of comments different things, but they are usually to these esoteric ends rather than "just for nostalgic 'membering".

    被当成教条的写作规则(“注释是坏味道”)常被误读,需要结合具体语境加以辨析。

    在跟“clean coder”们争论时,这篇文章很好用。那些人认为 Uncle Bob 反对注释,大概是误解了他的书或推文。不过,需要这样的争论本身就说明这个行业还不够成熟。

    tester756查看英文原文

    Handy article when arguing with "clean coders"* about comments * people who claim that UB's against them due to misunderstanding(?) his book/tweets(?), dunno. Anyway the need for those discussions is an indicator of how this industry hasn't matured yet

    同类还值得读

    1. 编写更好文档的框架

      A Framework for Writing Better Documentation

      这是 Divio 的文档写作框架,把技术文档按「读者的目标」分成四类:教程(学习导向)、操作指南(问题导向)、参考(信息导向)、解释(理解导向)。

      技术写作与文档2021 · 637 分 · 76 评4 条写作要点编辑精选
    2. 写好一份设计文档

      Writing a good design document

      这篇 HN 帖子标题为《Writing a good design document》,主题是如何写好一份设计文档;对写作者来说,它值得作为技术写作和结构化说明文的参照。

      技术写作与文档2025 · 581 分 · 147 评3 条写作要点编辑精选
    3. 技术写作课程

      Technical Writing Courses

      这是 Google 官方免费技术写作课程(两门),讲受众定义、主动语态、短句、文档结构等基础方法。

      技术写作与文档2020 · 571 分 · 73 评4 条写作要点编辑精选
    4. 写出更好的错误信息

      Write better error messages

      这篇帖子讨论如何写出更好的错误信息,评论补充了开发者场景下的具体做法和真实反面案例。

      技术写作与文档2022 · 566 分 · 253 评4 条写作要点编辑精选
    5. 写一本技术书的经济账

      The Economics of Writing a Technical Book

      一位技术书作者拆解写书的真实经济账:版税收入往往远低于投入的时间成本。

      技术写作与文档2018 · 519 分 · 149 评4 条写作要点编辑精选

    打赏支持

    打赏二维码

    觉得有用,请作者喝杯咖啡。

    WeChat

    关注向阳乔木

    微信公众号「向阳乔木推荐看」

    微信公众号「向阳乔木推荐看」二维码

    微信扫一扫;在微信里打开本页时,长按二维码识别。