惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
J
Java Code Geeks
Vercel News
Vercel News
A
About on SuperTechFans
G
Google Developers Blog
C
Check Point Blog
腾讯CDC
N
Netflix TechBlog - Medium
博客园 - 司徒正美
S
SegmentFault 最新的问题
D
DataBreaches.Net
博客园_首页
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
量子位
雷峰网
雷峰网
IT之家
IT之家
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
博客园 - 三生石上(FineUI控件)
H
Help Net Security
宝玉的分享
宝玉的分享
博客园 - 叶小钗

博客园 - ffl

用AI像大一新生一样学东西 [AI翻译]我如何用大模型写软件 [AI翻译]来自Zig的教训 [AI翻译] 标题:Agentic AI 手册:生产级模式 [AI翻译]:我们如何让 Python 的 packaging 库提速三倍 翻译:Akin 的航天器设计法则 Navida和Groq的交易资金多么? 翻译:这并不是未来 一个完整的软件开发过程,AI在哪些地方加速? 从业务读写流程出发,理解各种分布式系统组件的意义 【AI翻译】什么是第三方API?优势、应用场景与最佳实践 【AI翻译】分布式系统中的心跳机制 【AI翻译】Python 3.14来了,有多快? Argo CD 与 Kubernetes 资源关系简述 技术文章阅读todo-list DLM(Diffusion Language Model) vs AR(Autoregressive) 标注的原理:少而完备,监督模型训练的根本 几何平均比算术平均对极值不敏感。 对比理解:什么是AI味浓厚的文章? 重要文章:Asymmetry of verification and verifier’s law
类型标注,太多和太少一样糟糕
ffl · 2025-12-15 · via 博客园 - ffl

https://news.ycombinator.com/item?id=46266102

一位工程师的回复:

A few things I've come to personally believe after spending years developing web and robotics software in Python/JavaScript then spending years having to maintain while constantly adding new features and dealing with company pivots:

  • The types exist whether you write them down or not.
  • If they're not written down, they're written down in your head.
  • Your head is very volatile and hard for others to access.
  • Typing is an incredibly good form of documentation.
  • JSDoc and TypeScript are standards/formats for typing. Like any tools, they both have advantages and disadvantages. Neither is objectively better than the other.
  • Make informed decisions on how you'll describe your types, and then be consistent and unsurprising.
  • A type checker is the computer saying, "okay then, prove it" about your program's type validity.
  • Not every program benefits from the same amount of "prove it."
  • Too much can be as bad as too little. You're wasting resources proving throwaway code.
  • I like languages that let you decide how much you need to "prove it."

翻译:

经过多年用 Python/JavaScript 开发 Web 和机器人软件、以及在不断新增特性、应对公司方向调整时负责维护这些代码后,我个人的一些体会:

  • 无论你是否写下来,类型始终都存在。
  • 如果你没把类型写成文档,那它们其实都记在你脑子里。
  • 你的大脑极其容易遗忘,而且别人很难读取你的想法。
  • 类型标注是一种极佳的文档形式。
  • JSDoc 和 TypeScript 是描述类型的标准和格式。像所有工具一样,它们各有优缺点,没有哪一个绝对好于另一个。
  • 要对如何描述类型做出有根据的决策,并保持一致性和可预期性。
  • 类型检查器其实就是计算机对你说:“那好,请你证明下你的程序类型是对的。”
  • 并不是每个程序都需要同样严格的“证明”。
  • 太多类型验证和太少一样,都不好。你可能会浪费时间去验证一些一次性代码。
  • 我喜欢那些可以让你自己决定“需要证明到什么程度”的编程语言。