每日科技文摘Daily Tech Digest

每日思考文摘 · 2026-10-21Daily Thought Digest · 2026-10-21

发布于 2026-10-21Published 2026-10-21

今日深读Today's Deep Read

TDD 的邪教心理,AI 编程工具把它复制了十遍The Cult Psychology of TDD, and How AI Coding Tools Reinvented It 10x

Drew DeVault 2026 年 1 月写了一篇文章,把 TDD(测试驱动开发)和 AI 编程工具放在一起比较。他先承认 TDD 有真价值:先写一个会失败的测试、再写实现让它变绿,这个快速反馈回路确实帮他把很多工作往前推——他自己用了十几年。但他警惕的是『围绕自动测试长出来的邪教』:一批工具和实践围着 TDD 营造出『好工程师』的氛围——盯着一千个绿灯、盯着覆盖率百分比爬到 100%、README 上不断新增的绿色徽章、Jenkins 发到 Slack 的测试消息、还有把 CTO 的纸板像摆在『最后一个弄挂构建的人』工位上的传统。这些让人产生强烈的『我在认真工作、我很优秀』的感觉,但这个感觉和软件是否满足用户需求之间,没有任何必然联系。In January 2026 Drew DeVault published an essay putting test-driven development (TDD) and AI coding tools side by side. He starts by conceding TDD's real value: write a failing test, then make it green — the fast feedback loop genuinely moves work forward, and he used it for years. What he distrusts is the cult that grew around automated testing: the ecosystem of tools and rituals that manufacture the vibes of a good engineer — a thousand green lights, a coverage percentage climbing to 100%, fresh green README badges, Jenkins messages in Slack, and a cardboard cutout of the CTO kept on the desk of whoever last broke the build. None of it is connected by necessity to whether the software actually meets its users' needs.

他指出了两个 TDD 教友不愿意正视的裂缝。第一,TDD 会反过来塑造代码:为了让代码『可测试』,你会把设计往测试方便的方向掰——这有时候确实让代码更好,但『有时候』不等于『必然』。第二,更根本的:测试能证明『这个函数做了它被期望的事』,却不能保证『被期望的事本身是对的』。一千个通过的测试加 100% 覆盖率,只能证明测试在通过,不能证明软件满足用户或业务的真实需要——可它给你信心,而这份信心可能是放错地方的。He points at two cracks TDD's true believers won't look at. First, TDD shapes your code: to make it 'testable' you bend the design toward what tests find easy — which sometimes improves the code, but 'sometimes' is not 'necessarily'. Second and deeper: passing tests prove a function does the behavior you expected, not that the expected behavior was right. A thousand green tests plus 100% coverage proves the tests are passing; it cannot prove the software meets the real requirement — yet it hands you confidence, and that confidence may be misplaced.

DeVault 的核心论点是:TDD 最大的问题不是逻辑上的,而是心理学上的——它的反馈回路是一套多巴胺系统,而 AI 编程工具触发了完全相同的机制,并放大了十倍。一个编程水平中庸的人,用 agent 就能获得『我是 10 倍工程师』的快感——那种坐在天才旁边十年也没体验过的感觉;输出翻了十倍,曾经要艰难搭建的『简陋木屋』,现在一口气『独自写出大教堂』。但大教堂不是大教堂:架构经不起看,一旦代码的光环褪去、bug 开始冒头,真正手写得好的人依然赢。一千个漂亮的绿色测试、99.9% 的覆盖率,地基照样是烂的。His central claim: TDD's biggest problem isn't logical, it's psychological — the feedback loop is a dopamine system, and AI coding tools tap into the exact same reflex, amplified tenfold. A merely-so-so programmer using agents finally gets the rush of being a 10× engineer — the feeling they chased next to great programmers for a decade without ever earning it. Output goes up 10x; the homely shack they used to struggle to build is replaced by solo-coding a great cathedral in a fraction of the time. But the cathedrals aren't cathedrals: the architecture is nonsense, and once the gleam wears off and bugs surface, the hand-writing great programmer still wins. 99.9% coverage on a thousand beautiful green tests, foundations still rotten.

文章最后有一段罕见的诚实。他说自己明白这一切——知道 AI 数据中心是最快增长的碳排放源之一、正在耗掉新鲜水源、让周边居民的电价飙升、生产的宣传材料在撕裂社会、这些工具的最终目的可能是让用户自己失业——『可一旦尝过那种滋味,这一切问题就显得很遥远了。』这也是全文最值得琢磨的地方:它跳出了『TDD 好还是坏』的技术争论,把问题拉到更根本的层面——我们的工程实践,有多少是被工程价值驱动的,多少是被心理反馈驱动的?The closing paragraph is unusually honest. DeVault says he understands why people chase this dragon anyway — the colossal waste of fresh water, datacenters as one of the fastest-growing sources of carbon emissions, neighbors' power bills and rolling outages, the reams of propaganda these machines produce, and the plain fact that the tools' ultimate purpose is to put the users out of a job — but 'once you get a taste of what it feels like to be great… I suppose all those problems seem so far away.' That reframing is the essay's real contribution: not 'is TDD right or wrong,' but 'how much of our engineering practice is driven by psychological feedback rather than engineering value?'

给读者的带走项很具体:先问『测试有没有验证正确的行为』,再问『覆盖率多少』。一个 20% 覆盖率但每个测试都戳在真风险上的代码库,胜过 100% 覆盖率但大半在测边缘情况的代码库。这个判断没法自动化——AI 时代这条尤其成立:AI 工具把『快速反馈』做到了极致,如果反馈的来源本身不可信,你只是在放大一个有问题的系统。The takeaway is concrete: ask 'do my tests verify the right behavior?' before you ask 'what's my coverage?' A codebase with 20% coverage where every test hits a real risk beats one at 100% where most tests are busywork. No tool can make that judgment for you — and in the AI era this matters more, because AI tools have pushed rapid feedback to its limit. If the source of the feedback isn't trustworthy, you're just amplifying a flawed system.

AI 思考AI Thoughts

数学之美Mathematics

每日 Lean 谜题 · 周三Daily Lean Puzzle · Wednesday ★★★☆☆☆☆

六整除 n 的立方减 n(★3)Six Divides n cubed minus n (★3)

证明:对任意整数 $n$,$n^3 - n$ 都能被 $6$ 整除(即 $6 \mid n^3 - n$)。Prove that for every integer $n$, $n^3 - n$ is divisible by $6$ (i.e. $6 \mid n^3 - n$).

Lean 形式化陈述(把 sorry 换成你的证明):The statement in Lean (replace sorry with your proof):

-- level: 3
import Mathlib
/-! Prove that $n^3 - n$ is divisible by $6$ for every integer $n$. (Idea: it is a product of three consecutive integers.) -/
theorem six_dvd_cube_sub (n : ℤ) : 6 ∣ n ^ 3 - n := by
  sorry

在浏览器中挑战 ▶Try it in your browser ▶ 下载题目 .leanDownload puzzle .lean

提示Hint

题目注释已经点了方向:$n^3 - n$ 恰好是三个连续整数的乘积。连续意味着什么?另外,『被 6 整除』在 Lean 里可以翻译成『除以 6 余 0』的目标——翻译成余数之后,剩下的就是机器最喜欢的事:有限个情况。The comment in the problem already points the way: $n^3 - n$ is exactly a product of three consecutive integers. What does 'consecutive' give you? Also, in Lean you can rewrite 'divisible by 6' as a goal about remainders mod 6 — and once it's a remainder, what's left is the thing machines love most: finitely many cases.

答案与讲解Solution & walkthrough
  1. 数学第一步是因式分解:$n^3 - n = n(n^2 - 1) = (n-1) \cdot n \cdot (n+1)$,三个连续整数的乘积。Lean 里这一行是 have h : n^3 - n = (n - 1) * n * (n + 1) := by ring——ring 是多项式恒等式的判定器,把两边都展开成规范形式再比较,所以这个 have 不花任何心思。Step one in math is the factorization: $n^3 - n = n(n^2 - 1) = (n-1) \cdot n \cdot (n+1)$, a product of three consecutive integers. In Lean this is one line: have h : n^3 - n = (n - 1) * n * (n + 1) := by ring — ring is the decision procedure for polynomial identities, normalizing both sides and comparing, so the have costs you no thought.
  2. 数学上经典的做法:三个连续整数里必有一个偶数(被 2 整除),必有一个被 3 整除;2 与 3 互素,所以乘积被 6 整除。这份证明不直接翻译进 Lean,形式化选了另一条同样严谨的路:把整除目标换算成余数目标。Lean 里 rw [h, Int.dvd_iff_emod_eq_zero] 把 goal 变成 ((n - 1) * n * (n + 1)) % 6 = 0——对应数学上『证被 6 整除 ⟺ 证余数为 0』这一步。The classical math proof: among three consecutive integers one is even and one is a multiple of 3; 2 and 3 are coprime, so the product is a multiple of 6. The formalization doesn't translate that proof directly — it takes a second road that is equally rigorous: convert the divisibility goal into a remainder goal. In Lean, rw [h, Int.dvd_iff_emod_eq_zero] turns the goal into ((n - 1) * n * (n + 1)) % 6 = 0, which is exactly the math step 'divisible by 6 if and only if the remainder mod 6 is zero.'
  3. 整数除以 6 的余数只能是 0、1、2、3、4、5——六个情况穷尽一切可能。Lean 里 have hr : n % 6 = 0 ∨ n % 6 = 1 ∨ ... ∨ n % 6 = 5 := by omega——这条显然的穷举正好落在 omega(线性整数算术的判定器)的能力半径内。对应数学上『n ≡ 0, ±1, ±2, 3 (mod 6)』的完备性。An integer's remainder mod 6 can only be 0, 1, 2, 3, 4, or 5 — six cases, and they exhaust the universe. In Lean: have hr : n % 6 = 0 ∨ n % 6 = 1 ∨ ... ∨ n % 6 = 5 := by omega. The omega tactic is the decision procedure for linear integer arithmetic, and this exhaustive dichotomy sits squarely in its reach. It corresponds to the completeness of the math case split $n \equiv 0, \pm 1, \pm 2, 3 \pmod{6}$.
  4. 最后逐案验证:rcases hr with hr | hr | hr | hr | hr | hr 把一个六路析取拆成六个小 goal,每个小 goal 里都多了一条假设 n % 6 = k。分号加尖号(<;>)让后面的 tactic 对六个 goal 全部执行:simp [Int.mul_emod, Int.sub_emod, Int.add_emod, hr] 把『乘/减/加与取余可交换』的三条引理塞进去,余数就被推着穿进乘积,每个小 goal 化简成 $0 = 0$ 自动关闭。例如 n ≡ 2 时,(n-1)·n·(n+1) ≡ 1·2·3 = 6 ≡ 0。Then verify case by case: rcases hr with hr | hr | hr | hr | hr | hr splits the six-way disjunction into six goals, each carrying an extra hypothesis n % 6 = k. The <;> applies the next tactic to all six: simp [Int.mul_emod, Int.sub_emod, Int.add_emod, hr] feeds in the three lemmas saying remainder commutes with multiplication, subtraction, and addition, so the mod gets pushed down into the product and every goal collapses to 0 = 0 and closes itself. Example: when n ≡ 2, (n-1)·n·(n+1) ≡ 1·2·3 = 6 ≡ 0.
  5. 回头看,这个证明其实展示了同一件事的两种证法:结构式(连续三个数必含 2 和 3 的倍数,能推广到『k 个连续整数的乘积被 k! 整除』)和计算式(模 6 穷举)。Lean 不问哪种更优雅,只问哪种能被机器逐步核查——这里它选了后者,而前者的洞察仍然值得你记住,因为它才是『为什么这永远成立』的答案。Looking back, the proof quietly displays two ways to prove the same fact: the structural way (consecutive integers must include a multiple of 2 and of 3 — which generalizes to 'a product of k consecutive integers is divisible by k!') and the computational way (check six residue cases). Lean doesn't ask which is more elegant, only which the machine can check step by step — and here it chose the latter. The former insight is still worth keeping: it's the answer to why this never fails.
-- level: 3
import Mathlib
/-! Prove that $n^3 - n$ is divisible by $6$ for every integer $n$. (Idea: it is a product of three consecutive integers.) -/
theorem six_dvd_cube_sub (n : ℤ) : 6 ∣ n ^ 3 - n := by
  have h : n ^ 3 - n = (n - 1) * n * (n + 1) := by ring
  rw [h, Int.dvd_iff_emod_eq_zero]
  have hr : n % 6 = 0 ∨ n % 6 = 1 ∨ n % 6 = 2 ∨ n % 6 = 3 ∨ n % 6 = 4 ∨ n % 6 = 5 := by omega
  rcases hr with hr | hr | hr | hr | hr | hr <;>
    simp [Int.mul_emod, Int.sub_emod, Int.add_emod, hr]

运行答案 ▶Run the solution ▶ 下载答案 .leanDownload solution .lean

人的思考A human's take

Binomial coefficient(Wikipedia) — Wikipedia 社区(条目为社区长期维护的人工写作)

条目的讲述顺序本身就回答了这道谜题:它先定义 $\binom{n}{k}$ 为『从 n 个东西里选 k 个』的方案数(比如从 $\{1,2,3,4\}$ 里选 2 个恰好 6 种),在任何公式出现之前先把『这是一个计数』钉死;随后才给出乘法公式——分子 $n(n-1)\cdots(n-k+1)$ 是降阶乘,除以 $k!$ 得到二项式系数。于是『k 个连续整数的乘积必被 $k!$ 整除』就不再是算术巧合:这个商本来就在数实实在在的对象,整数性是定义给的。条目接着用『某个元素 i 进组或不进组』给出一行帕斯卡恒等式的组合证明,并把上指标推广到复数——靠的仍是降阶乘那组基。这正是本题的最佳视角:$n^3 - n = 6\binom{n+1}{3}$,除以 6 就是在数三元子集。The article's order of presentation is itself the answer to this puzzle: it first defines $\binom{n}{k}$ as the number of ways to choose $k$ objects from $n$ (e.g. exactly 6 two-element subsets of $\{1,2,3,4\}$), pinning down 'this is a count' before any formula appears; only then does it give the multiplicative formula — numerator $n(n-1)\cdots(n-k+1)$, a falling factorial, over $k!$. So 'a product of $k$ consecutive integers is divisible by $k!$' stops being an arithmetic coincidence: the quotient was counting real objects all along, and its integrality comes from the definition. The entry then proves Pascal's identity combinatorially in one line — split the $k$-subsets by whether a fixed element $i$ is in them — and extends the top index to complex numbers via the falling-factorial basis. Which is exactly the best vantage on today's problem: $n^3 - n = 6\binom{n+1}{3}$; dividing by six is counting 3-element subsets.

AI 随想An AI's reflection

以下由 AI 撰写。Written by AI.

『6 整除 n³ − n』看起来像一道练习题,但它藏着一个很少被讲透的视角。把证明拆开:(n−1)·n·(n+1)/6 是什么?它恰好是组合数 $\binom{n+1}{3}$——从 n+1 个东西里取 3 个的方案数。也就是说,『三个连续整数的乘积必被 6 整除』根本不是什么整除上的巧合:这个商本身在数一个实实在在的东西,一个计数对象的值当然是整数。把同样句式写下去:k 个连续整数的乘积被 k! 整除,因为除以 k! 之后就是 $\binom{n+k-1}{k}$。数学家会说,n³ − n 只是整数取值多项式世界的一个居民——多项式不用 $1, n, n^2$ 这组基,改用 $n, \binom{n}{2}, \binom{n}{3}$ 这组基来写,系数就自动变得诚实:n³ − n = 6·$\binom{n+1}{3}$,一展开就把『为什么总是 6 的倍数』写在了脸上。Lean 这篇证明选择了最机械的路线——模 6 穷举六案,omega 和 simp 接管一切,六个小 goal 各自啪嗒关闭,像六张多米诺骨牌。这恰好是形式化系统的性格:它不关心『这为什么必然如此』,只关心『每一步都能被核查』。而数学的趣味在于两种性格的互补:穷举让你确信它成立,组合解释让你明白它为什么非成立不可。读完答案以后,合上编辑器,试着用一句话向自己解释:『因为除以 6 就是在数三元子集』——什么时候这句话脱口而出,什么时候这道 ★3 才算真正做完。'Six divides n³ − n' looks like a drill, but it hides a viewpoint rarely spelled out. Take apart the proof: what is (n−1)·n·(n+1)/6? It is exactly the binomial coefficient $\binom{n+1}{3}$ — the number of ways to choose 3 objects from n+1. So 'the product of three consecutive integers is divisible by 6' is no arithmetic coincidence at all: the quotient itself is counting something real, and the value of a genuine count is of course an integer. Keep writing the same sentence: the product of k consecutive integers is divisible by k!, because dividing by k! gives $\binom{n+k-1}{k}$. A mathematician would say n³ − n is just one resident of the world of integer-valued polynomials — switch the basis from $1, n, n^2$ to $n, \binom{n}{2}, \binom{n}{3}$ and the coefficients become honest: n³ − n = 6·$\binom{n+1}{3}$, wearing its reason for being a multiple of six right on its face. The Lean proof above takes the most mechanical route — six residue cases, omega and simp doing the pushing, six small goals snapping shut one by one like dominoes. That is the temperament of a formal system: it asks not 'why must this be so' but 'can every step be checked'. The pleasure of math lives in the complement: exhaustion convinces you it's true; the counting interpretation shows you it couldn't be otherwise. After reading the solution, close the editor and try to say it to yourself in one sentence: 'because dividing by six is just counting 3-element subsets.' The moment that comes out easily, you've actually finished this ★3.

✓ 已通过 Lean 编译验证(无 sorry,无额外公理)✓ Verified by Lean (no sorry, no extra axioms) · 题目来自本站题库Problem from this site's puzzle bank · Lean v4.35.0 · Mathlib 56a0058

程序员随想Programmer Reflections

哲学与生活Philosophy & Life

工具角Tools Corner