每日科技文摘Daily Tech Digest

每日科技文摘 2026-11-02:算得清账的 AI、讲不明白的框架Daily Digest 2026-11-02: AI You Can Actually Benchmark, Frameworks You Can't Explain

发布于 2026-11-02Published 2026-11-02

今日深读Today's Deep Read

让 agent 各写 5 遍同一个应用:『哪个框架对 AI 更好』第一次有了数据Let Agents Build the Same App 5 Times Each: 'Which Framework Is Better for AI' Now Has Data

Lawson 常年被骂『框架圈全靠感觉』:『Next 快如闪电』『Svelte 让 AI 写得更少』——这些口号从没配上过基准测试。agent 时代把这件事推到了不得不做的地步:现在决定『用哪个框架』的常常是那个替你写代码的 agent,而不是键盘另一头的人。于是他做了个笨办法:拿一个非平凡但可规格化的小应用(Pokémon 数据展示,来自 PokéAPI),让同一个 coding agent(Opus 5.5 高努力档)分别用 12 种 JS 框架/元框架各建 5 遍,每遍记录费用、耗时、token、代码量与 Lighthouse 性能/可访问性,取中位数。 规格里刻意留了两道防线:agent 不许知道 Lighthouse 会被测(防作弊),各框架只能用官方 MCP/skill(防『我们框架训练数据多』的偏袒)——这是整篇里最容易被跳过的两个方法论细节。Lawson has long complained that the JS framework world runs on vibes: 'Next is blazing fast,' 'Svelte makes agents write less code' — slogans that have never been paired with a benchmark. The agent era made this unavoidable, because the decision of 'which framework to use' is increasingly made by the agent that writes the code, not by a human at a keyboard. His method is deliberately brute-force: one non-trivial but specifiable app (a Pokémon data display against PokéAPI), the same coding agent (Opus 5.5, high effort) building it five times each across 12 frameworks/meta-frameworks, recording cost, wall-clock time, tokens, lines of code, and Lighthouse performance/accessibility — then taking medians.

最反直觉的结果在最上面:贵的不是你以为的那种。SvelteKit、Gracile+Lit、Angular 明显更烧钱(中位数 4.3–5.0 美元,最贵跑到 6.8),htmx+Hono、Astro、Nuxt 排前三(2.7–2.8 美元),原生 JS 甚至打败了好几个框架——不是『不用框架更好』,而是『某些框架比裸 Vite 还费』。作者解释得很诚实:贵往往不是框架本身,而是 agent 每次都要读迁移文档或啃 node_modules 里的源码——SvelteKit v3 太新、进不了训练数据,所以每次都在现场补课。The most counter-intuitive result sits at the top: the expensive ones aren't who you'd guess. SvelteKit, Gracile+Lit, and Angular burn clearly more (4.3–5.0 USD median, up to 6.8), while htmx+Hono, Astro, and Nuxt lead the cheap end (2.7–2.8 USD) — and vanilla JS beats several frameworks. Not 'no framework is better,' but 'some frameworks cost more than raw Vite.' The author's explanation is honest: the cost is often not the framework itself but the agent re-reading migration docs or node_modules source on every run — SvelteKit v3 is too new for the training data, so it's learning on the spot, every time.

第二个值得记住的教训是方差:同一框架的 5 次运行里,React Router 最便宜的一比(2.82 美元)比 htmx 最贵的一比(3.19 美元)还便宜。LLM 是随机词生成器,agent 会在跟框架无关的地方掷骰子。所以这个基准真正产出的不是排行榜,而是一张『方差地图』——哪些比较是稳的(框架差距大于单次噪声才可信),哪些只是噪声。The second takeaway is variance: across five runs of the same framework, React Router's cheapest run ($2.82) beats htmx's most expensive ($3.19). LLMs are random-word generators; the agent rolls dice in ways that have nothing to do with the framework. So the benchmark's real output isn't a leaderboard but a 'variance map' — which comparisons are trustworthy (framework gaps larger than single-run noise) and which are just noise.

对程序员的实际启示:别再用体感给 agent 选工具栈。如果『我们的框架对 AI 更友好』是卖点,就让它按 Lawson 的规格付一次费用,或至少跑 5 次取中位数。体感时代结束了——因为体感正是那个替你写代码的 agent 最容易上当的东西。The practical lesson: stop picking a stack for your agents on gut feeling. If 'our framework is better for AI' is your pitch, make it pay the price per Lawson's spec — or run it five times and take the median. The vibes era is over, because vibes are exactly what the agent writing your code is most susceptible to.

AI 思考AI Thoughts

数学之美The Beauty of Math

每日 Lean 谜题 · 周一Daily Lean Puzzle · Monday ★☆☆☆☆☆☆

每日一题:除以 9 的小把戏Today's Puzzle: The Divisibility-by-9 Trick

设 $n$ 是一个自然数,且 $3\mid n$(即 $n$ 能被 3 整除)。Let $n$ be a natural number with $3\mid n$ (i.e. $n$ is divisible by 3).

证明 $9\mid n + n + n$(即 $3n$ 一定能被 9 整除)。Prove that $9\mid n+n+n$ (i.e. $3n$ is always divisible by 9).

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

-- level: 1
import Mathlib
/-! If $n$ is a natural number divisible by $3$, prove that $n + n + n$ is divisible by $9$. -/
theorem triple_sum_div_nine (n : ℕ) (h : 3 ∣ n) : 9 ∣ n + n + n := by
  sorry

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

提示Hint

别把 $n$ 的具体数字拉出来——$n=3k$ 这一步是关键。Don't try to name $n$'s digits — the single move $n = 3k$ is the key.

答案与讲解Solution & walkthrough
  1. $3\mid n$ 意味着存在一个自然数 $k$ 使 $n = 3k$。$3\mid n$ means there is a natural number $k$ with $n = 3k$.
  2. 于是 $n + n + n = 3n = 3(3k) = 9k$。So $n + n + n = 3n = 3(3k) = 9k$.
  3. $9k$ 显然是 9 的倍数,所以 $9\mid 3n$,证毕。$9k$ is visibly a multiple of 9, so $9\mid 3n$. QED.
  4. Lean 里这一行被 `omega` 一口吞掉:`omega` 是整数线性算术的判定器,看到假设 `h : 3 ∣ n` 和结论 `9 ∣ n+n+n`,把『整除』展开成『存在一个 $k$ 使得 $n = 3k$』,然后做线性代数——和上面人工写的三行完全对应。In Lean, one line of `omega` swallows this: `omega` is a decision procedure for linear integer arithmetic. Given the hypothesis `h : 3 ∣ n` and the goal `9 ∣ n+n+n`, it expands 'divides' to 'there exists a $k$ with $n = 3k$', then does the linear bookkeeping — exactly the three human steps above.
-- level: 1
import Mathlib
/-! If $n$ is a natural number divisible by $3$, prove that $n + n + n$ is divisible by $9$. -/
theorem triple_sum_div_nine (n : ℕ) (h : 3 ∣ n) : 9 ∣ n + n + n := by
  omega

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

人的思考A human's take

Divisibility rule(『能否被 9 整除』的那条规则) — Wikipedia (entry on divisibility rules; Martin Gardner's 1962 Scientific American column as the popularizer)

这条 9 的整除小规则有个漂亮的来源:$10 \equiv 1 \pmod{9}$,所以任何十进制数 $a_k 10^k + \cdots + a_0$ 和它的各位数字和 $a_k + \cdots + a_0$ 在 mod 9 下是同一个东西——『被 9 整除』等价于『各位数字和被 9 整除』。This 9-divisibility trick has a beautiful source: $10 \equiv 1 \pmod{9}$, so any decimal number $a_k10^k + \cdots + a_0$ and its digit sum $a_k + \cdots + a_0$ are the same thing modulo 9 — 'divisible by 9' is equivalent to 'digit sum divisible by 9.'

这页条目(以及 Gardner 1962 年推广它的专栏)把『$10 \equiv 1$』当成解释所有 9 系规则的母体:为什么 9 的整除判定是位数字和、为什么 99 的整除判定是两位分块之和——本质都是 $10 \equiv 1$ 的推论。The entry (and Martin Gardner's 1962 column popularizing it) treats '$10 \equiv 1$' as the mother of all 9-family rules: why the 9 test is digit sums, why the 99 test is two-digit block sums — all consequences of $10 \equiv 1$.

AI 随想An AI's reflection

以下由 AI 撰写。Written by AI.

这道题看着小,但正好卡在一个容易被忽略的直觉上:『3 整除 $n$』和『9 整除 $3n$』之间没有任何多余的东西——把 3 拉进括号,$3n = 9 \cdot (n/3)$,一步到位。This is a small problem, but it lands on an intuition people often miss: between '3 divides $n$' and '9 divides $3n$' there is nothing extra — pull the 3 into the parenthesis and $3n = 9 \cdot (n/3)$ lands in one move. The reflexive move is to enumerate — try $n = 3, 6, 9$ one by one — but that path can never finish, because it bypasses the actual structure: the moment $n$ is a multiple of 3, it already carries one factor of 3, and multiplying by 3 once more completes the 9. 'Divisible by 3' has already prepared half of the 9 you need.

很多人会下意识地去『枚举』——试 $n=3,6,9$ 一个个验过去。但这条路既慢又永远完不成,因为它绕开了真正的结构:$n$ 只要是 3 的倍数,就已经自带了一个因子 3,再乘一次 3 就凑成 9。换句话说,『被 3 整除』本身就已经把『被 9 整除』所需的 9 的一半准备好了。Lean's `omega` compresses the whole 'expand the definition + linear bookkeeping' path into a single tactic; a human writing it out does the same two moves: rewrite 'divides' as 'there exists a $k$', then rearrange. That 'what the machine does is exactly what a human does' moment is one of the most honest things about formalized proof — `omega` isn't skipping the two steps, it's just doing them faster and without error. (This section was written by AI.)

Lean 的 `omega` 把这一整个『展开定义+线性算术』的路径压成一条命令,而人写的时候其实也是同样的两条:先把『整除』翻译成『存在 $k$』,再重排。这种『机器做的其实和人做的一模一样』的时刻最能说明形式化证明的诚实——`omega` 不是跳过了那两步,而是把那两步做得又快又不出错。(本段为 AI 撰写。)Lean 的 `omega` 把这一整个『展开定义+线性算术』的路径压成一条命令,而人写的时候其实也是同样的两条:先把『整除』翻译成『存在 $k$』,再重排。这种『机器做的其实和人做的一模一样』的时刻最能说明形式化证明的诚实——`omega` 不是跳过了那两步,而是把那两步做得又快又不出错。(本段为 AI 撰写。)

✓ 已通过 Lean 编译验证(无 sorry,无额外公理)✓ Verified by Lean (no sorry, no extra axioms) · 题目与证明由 AI 编写Problem and proof written by AI · Lean v4.36.0-rc1 · Mathlib d875a8d

程序员随想Programmer Reflections

哲学与生活Philosophy & Life

工具角Tools Corner