更好的电池
Better Batteries

原始链接: https://matklad.github.io/2026/08/20/better-batteries.html

关于标准库应当精简还是全面,这场争论忽略了真正的问题所在:**社会架构**。标准库的质量与成功,与其说是取决于规模,不如说是取决于设计、维护和迭代它的组织能力。 Python 通过“内置电池”(batteries-included)的理念证明了这一点,它将早期功能的实现置于一致性之上。尽管这导致了质量参差不齐和技术债,但也助推了 Python 在数据科学等领域的统治地位。相比之下,Go 语言因其全面且强大的库而备受推崇,其背后有着稳固的制度框架,确保了设计的一致性与可扩展性。 Rust 则呈现出不同的挑战。虽然其核心 API 设计精妙,但该语言在执行层面和长期扩展上却步履维艰。与 Go 成功将过剩产能转化为可维护的子项目不同,Rust 社区驱动的模式往往导致了一些项目停滞不前。 归根结底,作者认为标准库的成功——即便仅针对简单的技术任务——本质上是一个人类协调的问题。高水平的开发需要健全的组织架构、资金支持,以及解决现代编程语言生态中固有复杂社会障碍的能力。

这篇 Hacker News 讨论探讨了编程语言中“内置电池”(batteries included)的理念,权衡了强大的标准库所带来的收益与维护及版本控制挑战之间的利弊。 参与者认为,高质量的标准库(涵盖 JSON、日期和 Web 工具等基本功能)对于项目可靠性至关重要。然而,他们也指出了在提供“官方认可”的工具集与保持向后兼容性之间的内在矛盾。庞大的标准库可能导致臃肿和遗留代码(例如 Java 中长期废弃的日期处理方法),而像 Rust 这样极简主义的语言则将这一负担转移到了第三方生态系统中。 旨在弥合这一差距的建议包括: * **“扩展”标准库**:发布符合语义化版本规范(semver)的库,而非永久且不可更改的标准库。 * **接口优先设计**:提供标准化的特性(traits)或接口(如 JavaScript/TypeScript 的“标准模式”),允许开发者替换底层实现。 * **精选生态系统**:由官方指定“认可”的第三方包,在不增加核心语言臃肿度的情况下提供经过审查的官方方案。 最终,贡献者们认为,尽管实现完美的统一性很难,但能够提供稳定、高质量构建模块的语言可以显著降低开发者的负担和供应链风险。
相关文章

原文

One of the eternal schisms in programming is over the question of whether the standard library should be minimal or encompassing. This is the wrong question to ask. The right one is:

Which social architecture creates a high-quality standard library?

Python is always brought up as example of leaky batteries exploding in slow motion, but this has nothing to do with size. The problem with Python’s stdlib is its, ahem, uneven quality. Some standard library modules don’t follow language naming conventions! You know which unittest module I am talking about :-)

But even that is not a mistake. It’s actually Python core’s advantage — that it makes functionality available early, not thinking about the future too much. That’s how we ended up with ossified cAPI which makes CPython the language, but that is also how we ended up with Python powering data scientific revolution.

The Go standard library is similarly encompassing, but it is held in a high regard. Go team has institutional capacity to deliver well-designed API for the standard library, and then some: https://pkg.go.dev/golang.org/x

Rust is an interesting case. The 1.0 standard library APIs are brilliant. Collections and iterators are a work of art. But it also feels that, while the current team has the capacity to preserve existing APIs and fill in some gaps, the capacity to execute design decisions is limited. While golang.org/x captures excess capacity, rust-lang-nursery is a graveyard. Maybe I am over-indexing on my favorite hobby-horse, but it seems that the reason for Rust not having an API to get a stream of random bytes from the OS in 2026 is that, while it is an easy technical problem, it requires tricky organization architecture (including getting money in peoples’ pockets, of course) to actually get solved in the high-stakes environment of a world-wide coordination problem called a programming language.

联系我们 contact @ memedata.com