Luyao

理解简单

很偶然的,逛了一会关于 Unix 设计哲学的文章,看到一个很有趣的东西。

我们都知道接口简单很重要。

但事实上 Unix 的设计哲学中,实现的简单和接口的简单同样重要,而且这种简单性比系统的任何其他属性(正确性、一致性和完整性)都要重要。1 2

这很奇怪。

我不知道为什么这种简单性那么重要,它们是如何起作用的。

直到我读到下面这段话:

尽管 UNIX 系统引入了许多创新的程序和技术,但没有任何单一的程序或想法可以使其运行良好。相反,使其有效的是编程方法,一种使用计算机的哲学。尽管这种哲学不能用一句话来写下来,但其核心思想是,系统的力量更多地来自于程序之间的关系,而不是程序本身。许多 UNIX 程序单独做一些非常微不足道的事情,但是,与其他程序结合起来,就成为通用且有用的工具。

Even though the UNIX system introduces a number of innovative programs and techniques, no single program or idea makes it work well. Instead, what makes it effective is the approach to programming, a philosophy of using the computer. Although that philosophy can’t be written down in a single sentence, at its heart is the idea that the power of a system comes more from the relationships among programs than from the programs themselves. Many UNIX programs do quite trivial things in isolation, but, combined with other programs, become general and useful tools.

The Unix Programming Environment, Brian Kernighan and Rob Pike

也就是说,系统的力量更多来自于程序间的关系,而不是程序本身。

也就是说,联系是更重要的。

这就解释了,为什么实现和接口都很简单,是一个非常重要的原则,因为那会使程序间的相互关系变得简单。

接口的简单,使得程序易于被调用;而实现的简单,不仅使它更可靠,也使程序本身易于被其他人理解,只有理解了,才会与其他程序结合。


来自 2023/12/5 的补充: 朋友向我推荐了《能量,性,自杀》中的 “细菌为何如此简单” 章节,我大受震撼,和本文讲的事情很像。我应该另写一篇记录下来,但是最近太忙,没有时间了。


  1. Unix Philosophy ↩︎

  2. Worse is better ↩︎