每日思考文摘 · 2026-10-26Daily Thought Digest · 2026-10-26
发布于 2026-10-26Published 2026-10-26
今日深读Today's Deep Read
重写世界的成本突然便宜了:为什么大多数程序员还在用旧时代的成本模型When Rewriting the World Got Cheap: Why Most Programmers Still Use Last Era's Cost Model
今年初,Postgres 开发者 Michael Malis 一直说『我们该把软件写得更大胆一些』。这句话听上去像口号,但 Dan Luu 在 10 月 24 日这篇帖子里把它落实成了具体的证据:pgrust 项目在做的事是——用 Rust 重写 Postgres 的查询层。这个规模的项目,按旧成本模型,需要一支团队花几年才有产出;而 Malis 已经靠它找到 Postgres 里好几个真实的 bug(数值 bug 导致 SP-GiST 操作失败、JSONPath 缓存错误、pgcrypto 后续操作失败、字典加载器的内存安全 bug、金额溢出 bug)。Luu 的原话很关键:『即使 pgrust 本身最终失败了,光是做这个尝试,就已经让 Postgres 永久变好了。』Early this year, Postgres developer Michael Malis kept telling people 'we should be more ambitious with the software we build.' It sounds like a slogan, but Dan Luu's October 24 post turns it into concrete evidence: pgrust, a project to rewrite Postgres's query layer in Rust, is the kind of project that under the old cost model would take a team years. Instead, Malis has already found real bugs in Postgres through it — a numeric bug breaking valid SP-GiST operations, a JSONPath cache bug producing wrong results, a pgcrypto bug, memory-safety bugs in the dictionary loader, a money-overflow bug. Luu's key line: even if pgrust itself never succeeds, just attempting it has made Postgres permanently better.
Luu 接下来做了一个他自己在其他领域也验证过的事情:他不懂正则引擎,但现在可以花『个位数小时』写出一个比通用正则库在自己特定工作负载上更快的引擎;他不懂编译器,但 fork 了 Rust 的 ripgrep 让它编译自己的正则;他甚至不打算自己造轮子去做『直接 I/O』或自定义文件系统——因为这些事情在 AI 编码助手能力暴涨之前,对一个没有对应背景的人来说,是那种『只会让永远不会发货的人才会去碰』的事。他的观察是:『我最有生产力的几个同事到现在还保留着对这类项目的本能抗拒,即使这类项目现在其实完全合理。』Luu has verified the same pattern in other domains: he knows nothing about regex engines, but now spends single-digit hours building one faster than the general-purpose libraries on his own workloads; he forks ripgrep so its regex backend compiles; he's not even willing to build his own direct-I/O or filesystem layer, because those are now things a person with no background in the area can 'get good enough.' His observation: several of his most productive colleagues still carry a reflexive aversion to this kind of project, even though it's now genuinely reasonable to attempt it.
他还补充了一个更细的对比:他之前用 GPT-5.1/5.2 做棋牌 AI,花了约 5 小时才做到『超人级』,约 20 小时做到当时公开平台(Board Game Arena)上最强的一个,中间大部分时间花在纠正模型『表面像某个技术、但其实没做对』的实现上。换成 Fable 5.1 和 Opus 5.5 之后,模型能直接读懂论文并正确实现里面的技术,这个纠正过程几乎消失了——对没有该领域背景的人来说,这是时间成本数量级的变化。He also adds a finer-grained comparison: doing board-game AI with GPT-5.1/5.2 took him roughly 5 hours to reach superhuman play and 20 hours to reach the strongest public engine on Board Game Arena, mostly spent correcting the model's 'looks like the technique but isn't' implementations. With Fable 5.1 and Opus 5.5, the model reads the paper and implements the technique correctly — for someone with no domain background, that's a change in the order of magnitude of the time cost.
核心论点其实很简单,但值得每个人重新想一遍:AI 没有让『大胆』本身变得可行,AI 改变了大胆行为在时间维度上的成本——过去需要整年、几乎注定做不完的事,现在是个位数小时就能『够用到』。大多数资深程序员判断『这事该不该做』时,脑子里跑的还是前 agent 时代的成本表。Luu 自己说,他本来想写的是『我们可以』而不是『我们该』——因为真正的问题不是道德上的应该,是成本模型过时了。The actual thesis is simple but worth everyone re-running: AI didn't make ambition possible — it changed the time cost of ambitious work. Something that used to be a year-long, almost certainly unfinished project is now a single-digit-hours 'good enough.' Most senior engineers deciding 'should we even attempt this?' are still running the pre-agent cost table in their heads. Luu says he'd have written 'we can' rather than 'we should' — the real issue isn't moral obligation, it's an outdated cost model.
AI 思考Thinking About AI
- 创意行业的岗位流失跟 Napster 时代有什么不同:一个经济学的坏类比What's Different Between Today's Creative-Job Loss and Napster's: A Bad Analogy, According to an Economist
- 起点(原文发表于 2026 年 9 月):过去四年美国『创意行业』(媒体、电影、艺术)丢了 20 万+ 岗位,最近一年单独就丢了 5 万,强度接近 2001/2008 衰退,但现在并没有全面衰退。Starting data (published September 2026): US 'creative industries' (media, film, arts) have lost 200k+ jobs over four years, roughly 50k in the last year alone — a decline comparable in intensity to the 2001/2008 recessions, but with no broad recession happening.
- 关键区分:作者把音乐业(Napster→Spotify)和电影/视频业分开处理——音乐有『演唱会』这条兜底线下收入,视频几乎没有对应物;所以视频业最坏情景其实更接近报业(整个商业模式崩塌),而不是音乐业(收入搬家到线下)。Key distinction: the author treats the music industry (Napster→Spotify) and film/video separately — music has a 'live concert' floor for income that video essentially lacks; so video's worst case looks more like newspapers (whole business model collapses) than like music (income relocates offline).
- 真正需要跟踪的指标:AI 在媒体里是『不可见的』,全行业约 32% 的从业者已经在用 AI,但消费者几乎察觉不到;这意味着『观众反感 AI 内容』这条兜底假设并不牢。The metric to actually track: AI inside media is invisible — about 32% of industry workers already use it, but consumers barely notice; so 'audiences will reject AI content' is not a reliable safety assumption.
- 作者不认为这能直接归因于 AI 本身(版权规避、Hollywood 内部整合、外包、社交替代新闻等都在同时发生),但指出所有数字艺术子行业同时下滑、而线下娱乐仍在健康增长,是 AI 影响最清晰的一个影子。The author does not attribute the decline directly to AI (copyright avoidance, Hollywood consolidation, offshoring, social media replacing news are all happening at once), but notes that all digital-arts subsectors declining while live entertainment keeps growing is the clearest shadow of AI's effect.
- 哪个模型最好?她把排行榜变成『预测这条 prompt 谁赢』:从 Chatbot Arena 到模型路由Which Model Is Best? Huyen Turns Leaderboards into 'Who Wins on This Prompt' — and into Model Routing
- 问题:选模型靠的是总体排行榜(Chatbot Arena 这类),但生产环境里你要回答的其实是『这一条 prompt 该给哪个模型』;而且部署过它的人告诉她,Arena 里多数投票者根本没读完两个答案就随机投——总体分数带着系统性噪声。Problem: model choice leans on aggregate leaderboards (Chatbot Arena and friends), but in production the real question is 'which model should get this one prompt' — and people who deployed Arena-style voting told her most voters never read both answers before voting randomly, so aggregate scores carry systematic noise.
- 关键改写:她论证『排行榜本质上是一个预测问题』。Elo、TrueSkill、Bradley-Terry 在同一份对战数据上会给出不同的排名——排名的质量只能用一个标准检验:它预测的赢家,和用户事后真实的选择是否一致。The reframe: she argues a ranking is, at bottom, a prediction problem. Elo, TrueSkill, and Bradley-Terry produce different rankings from the same match data — and a ranking can only be judged one way: do its predicted winners match what users actually prefer?
- 做法:她用约 3.3 万条历史对战(prompt + 两个模型 + 胜者)训练一个偏好预测器,输出是给定 prompt 下每对模型的预测胜率矩阵(比如『聚类文本嵌入的最好方法是什么?』这个问题上 GPT-4 对 GPT-3.5 的胜算)。The method: she trains a preference predictor on roughly 33K historical matches (prompt + two models + winner), producing, for any given prompt, a matrix of predicted win probabilities across model pairs — e.g. how likely GPT-4 beats GPT-3.5-Turbo on 'what's the best way to cluster text embeddings?'
- 用途一:模型路由——如果预先能预测某条 prompt 上用户更偏好便宜更快的模型,就直接路由过去,质量和成本/延迟同时改善;用途二:同一张矩阵就是一张模型可解释性地图,暴露每个模型在不同类型问题上的强弱。Use case one: model routing — if you can predict that users will prefer the cheaper, faster model on a given prompt, route it there and improve quality and cost/latency at once. Use case two: the same matrix doubles as an interpretability map of each model's strengths and weaknesses across prompt types.
- 可以带走的判断:排行榜回答『平均谁更强』,偏好预测回答『这条请求给谁』——后者才是每天掏钱的人真正要的问题。(原文 2024 年;『router』这个概念如今已经是各家模型网关的标配。)Takeaway: leaderboards answer 'who is stronger on average'; preference prediction answers 'who gets this request' — and the second is the question anyone paying the bill actually has. (Originally 2024; 'routers' have since become standard gear in model gateways.)
数学之美The Beauty of Math
每日 Lean 谜题 · 周一Daily Lean Puzzle · Monday ★☆☆☆☆☆☆
为什么 2 的 10 次方减 1 恰好被 11 整除Why 2 to the 10th, Minus 1, Is Exactly Divisible by 11
证明 $11$ 整除 $2^{10} - 1$,也就是 $2^{10} - 1$ 是 $11$ 的倍数。Prove that $11$ divides $2^{10} - 1$; that is, $2^{10} - 1$ is a multiple of $11$.
提示思路:不用真的算出 $2^{10}$,而是观察 $2^{10}$ 和 $2$ 的某次幂之间存在什么循环规律。Suggested direction: you don't actually need to compute $2^{10}$ — look for a cyclic pattern in the powers of $2$ modulo $11$.
Lean 形式化陈述(把 sorry 换成你的证明):The statement in Lean (replace sorry with your proof):
-- level: 1
import Mathlib
/-! Prove that $11$ divides $2^{10} - 1$. -/
theorem eleven_dvd_two_pow_10_minus_1 : 11 ∣ 2 ^ 10 - 1 := by
sorry
在浏览器中挑战 ▶Try it in your browser ▶ 下载题目 .leanDownload puzzle .lean
提示Hint
先算 $2^5$,再平方得到 $2^{10}$,看看模 $11$ 下会发生什么。Compute $2^5$ first, then square it to get $2^{10}$, and see what happens modulo $11$.
答案与讲解Solution & walkthrough
- 第一步(数学):先算 $2^5 = 32$。$32$ 除以 $11$ 余数是 $10$(也就是 $-1$ 模 $11$)。Step 1 (math): first compute $2^5 = 32$. Modulo $11$, that's $10$, i.e. $-1$.
- 第二步(数学):既然 $2^5 \equiv -1 \pmod{11}$,两边再平方:$2^{10} = (2^5)^2 \equiv (-1)^2 = 1 \pmod{11}$。Step 2 (math): since $2^5 \equiv -1 \pmod{11}$, square both sides: $2^{10} = (2^5)^2 \equiv (-1)^2 = 1 \pmod{11}$.
- 第三步(数学):$2^{10} \equiv 1 \pmod{11}$ 直接推出 $11 \mid (2^{10} - 1)$。Step 3 (math): $2^{10} \equiv 1 \pmod{11}$ immediately implies $11 \mid (2^{10} - 1)$.
- 第四步(Lean):Lean 里用 `decide` tactic 完成整个证明——它把『$11$ 是否整除 $2^{10}-1$』变成一个有穷的布尔判定,展开计算即可。Step 4 (Lean): in Lean, the `decide` tactic handles the whole proof — it reduces 'does $11$ divide $2^{10}-1$?' to a finite Boolean check and evaluates it.
- 第五步(理解 `decide` 的边界):这道题之所以适合用 `decide`,是因为两边的数字都有具体的上界($2^{10}=1024$,$1024-1=1023$,$1023 = 11 \times 93$),没有一般化的变量。如果题目换成『证明对所有 $n$,$11 \mid 2^n - 1$ 当且仅当 $10 \mid n$』,`decide` 就不够用了,需要归纳或更深入的群论工具。Step 5 (understanding `decide`'s limits): this problem works with `decide` because both sides have concrete numeric bounds ($2^{10}=1024$, $1023 = 11 \times 93$) with no general variables. If the problem were instead 'prove $11 \mid 2^n - 1$ iff $10 \mid n$', `decide` alone would no longer suffice — you'd need induction or deeper group-theoretic tools.
-- level: 1
import Mathlib
/-! Prove that $11$ divides $2^{10} - 1$. -/
theorem eleven_dvd_two_pow_10_minus_1 : 11 ∣ 2 ^ 10 - 1 := by
decide
人的思考A human's take
Musings on A New Interface for Mathematics (Jeremy Kun) — Jeremy Kun
这篇是 Kun 给他《程序员数学导论》写的收束章,主角是 Bret Victor 的『Kill Math』:Victor 厌恶纸笔符号操作,认为数学该有一种能实时操纵、立刻看到结果的『新界面』。Kun 大体同意底层判断——更好的界面历史上反复改造过数学:代数、近代符号记法、集合论、范畴论,每一次都让人能想『原本根本想不了的想法』;但他在意的是,Kun 指出符号记法恰恰是一种『能扩展复杂度』的界面:它可以操作画不出来、甚至逻辑上不存在的东西(反证法就靠这个),而且纸本身替人分担了一部分认知负荷。他给任何想替代记法的新界面开出四条标准:反事实推理、意义赋予、灵活复杂度(小孩和职业数学家都能用)、渐进主义(上手一个新话题不必先把该话题的全部知识编码进去)。Kun's essay, the closing chapter of his book 'A Programmer's Introduction to Mathematics,' is a dialogue with Bret Victor's 'Kill Math': Victor despises pencil-and-paper symbol shuffling and wants a math interface you can manipulate live, with instant feedback. Kun broadly accepts the underlying claim — better interfaces have repeatedly reshaped math: algebra, modern symbolic notation, set theory, category theory, each one letting people 'think thoughts that could not previously have been thought.' But he pushes back on the plan to replace notation: symbolic notation is itself an interface that scales complexity, letting you manipulate objects you can't picture and that may not even exist (proof by contradiction runs on exactly that), while paper offloads cognitive load. He then sets four desiderata any new interface must meet: counterfactual reasoning, meaning assignment, flexible complexity (usable by both a child and a working mathematician), and incrementalism (studying a topic shouldn't require first encoding everything known about it).
跟今天谜题的关系(注:以下是编者联想,非 Kun 原文):Lean 正踩在 Kun 划的那条线上——`decide` 一行把『11 是否整除 $2^{10}-1$』变成机器可核查的判定,这就是他说的『即时性』;但这道题真正的人类想法——先发现 $2^5 \equiv -1 \pmod{11}$、再平方——是界面替不掉的那一步,所以页面上的讲解把数学一侧和 Lean 一侧分开写。Relation to today's puzzle (note: the connection below is the editor's, not Kun's text): Lean sits right on the line Kun draws — the one-line `decide` turns 'does 11 divide $2^{10}-1$?' into a machine-checkable verdict, which is the immediacy he wants. But the puzzle's real human thought — noticing $2^5 \equiv -1 \pmod{11}$ and squaring — is the step no interface supplies, which is why the walkthrough separates the math side from the Lean side.
AI 随想An AI's reflection
以下由 AI 撰写。Written by AI.
这道题很小,小到一行 `decide` 就能关干净,但它是『模算术循环』这个想法最好的入门:任何一个质数 $p$,$2$ 的幂在模 $p$ 下都会形成一个循环,这个循环的长度($2$ 模 $p$ 的乘法阶)就是整除性判断的全部依据。This puzzle is tiny — one `decide` closes it completely — but it's the ideal introduction to the 'modular arithmetic cycle' idea: for any prime $p$, the powers of $2$ modulo $p$ form a cycle, and that cycle's length (the multiplicative order of $2$ mod $p$) is the whole basis for any divisibility question you'll ask.
今天选了 $11$,因为 $2^5 \equiv -1 \pmod{11}$ 这个中间结果特别干净——它让『平方一次』成为自然的下一步,比直接算 $2^{10}$ 短得多。这个『先找到一个负号、再平方掉它』的套路,在数论里出现频率高得惊人:Fermat 小定理、Euler 判别法、各种 Legendre 符号计算,底层逻辑都是同一个。We picked $11$ today because $2^5 \equiv -1 \pmod{11}$ is a remarkably clean intermediate result — it makes 'square it once' the natural next move, far shorter than computing $2^{10}$ directly. This 'find a minus sign, then square it away' pattern shows up over and over in number theory: Fermat's little theorem, Euler's criterion, Legendre-symbol computations all run on the same underlying logic.
作为周一的 ★1 谜题,它真正的考点不是『会不会按计算器』,而是你能不能在拿到一个陌生的模运算题目时,第一反应是找循环而不是硬算——这个直觉练熟了,后面的 ★2、★3 谜题(短证明、经典初等定理)就会顺手得多。As a Monday ★1 puzzle, the real test isn't 'can you do the arithmetic' — it's whether your first reflex on an unfamiliar modular-arithmetic problem is to look for the cycle, not to grind through the calculation. Once that reflex is automatic, the ★2 and ★3 puzzles ahead (short proofs, classic elementary theorems) fall into place much more easily.
✓ 已通过 Lean 编译验证(无 sorry,无额外公理)✓ Verified by Lean (no sorry, no extra axioms) · 题目与证明由 AI 编写Problem and proof written by AI · Lean v4.35.0 · Mathlib 56a0058
- 『NP-hard』不等于『很难』:它是最坏情形的陈述,不是给你的实例判的刑'NP-hard' Doesn't Mean 'Hard': A Worst-Case Claim, Not a Verdict on Your Instance
- 问题:每次有论文证明『超级马里奥是 NP-hard』,读者就理解成『马里奥无解』。Kun 直接反驳:这两件事没有关系——NP-hard 是一个很窄的数学术语,被媒体读宽了。Problem: every time a paper proves 'Super Mario is NP-hard,' readers conclude Mario is unplayable. Kun pushes back directly: the two claims are unrelated — NP-hard is a deliberately narrow term of math that media reading keeps inflating.
- 准确含义:NP-hard 说的是这个问题足够『有表达力』,能把布尔逻辑编码进去——给任意一个 SAT 公式,都能用关卡里砖块和管道的排布构造出『三选一 OR』这样的 gadgets,让『通关』等价于『公式可满足』。所以难的是那些蓄意构造的畸形关卡:NP-hardness 是一个最坏情形的陈述。The precise meaning: NP-hard says the problem is expressive enough to encode boolean logic — given any SAT formula you can lay out bricks and pipes as gadgets (an OR of three variables is one of them), so that beating the level equals satisfying the formula. The levels that encode logic formulas are contrived worst cases; NP-hardness is a worst-case statement.
- 再抽象一层:『难』其实是一族比较问题之间『解法可复用性』的想法——R 对于问题类 C 是难的,意思是『解 R 的算法』在有限制的资源下(NP-hard 要求变换只用多项式时间)能改装成『解 C 里任何问题的算法』;若 R 本身还属于 C,就叫 C-完全。找到完全问题是研究一个复杂度类的核心目标——Kun 打趣说业内口号是 'always be completing'。One layer more abstract: 'hardness' is really a family of ideas comparing problems by how reusable their solutions are — R is hard for a class C if an algorithm for R can be converted (with bounded resources; NP-hard demands polynomial-time conversions) into an algorithm for anything in C. If R is itself in C, it's called complete — and finding complete problems is the central aim of studying a complexity class (Kun's joke: 'always be completing').
- 现实的对照组:大数乘法对计算机 trivial、对人是苦差;蛋白质折叠是 NP-hard,却被做成了玩家真能帮忙科研的游戏;旅行商问题有实际算法,在『地球所有城市』规模的输入上几小时就能近乎最优。数学的难和实际的难基本脱钩。Reality's counterexamples: integer multiplication is trivial for computers and agony for humans; protein folding is NP-hard yet was turned into a game humans genuinely help science through; traveling salesman has practical algorithms that hit near-optimal solutions in hours on inputs as big as every city on Earth. Mathematical hardness and practical difficulty are largely disconnected.
- 能带走的判断:难/完全性结果不给你『做不做』的答案,而给你『该放弃什么、该往哪换』的答案——NP-hard 意味着别指望精确多项式算法,改用近似、启发式或真实实例的结构;P-完全(线性规划、LZW 压缩后的子串查询、partial types 的类型推断都在列)意味着别指望高效的并行算法。What you can take: hardness/completeness results don't tell you whether to bother — they tell you which hopes to trade away. NP-hard means stop expecting exact polynomial-time solutions and go for approximation, heuristics, or the structure of real instances; P-complete (linear programming, LZW compressed-string queries, type inference for partial types) means stop expecting efficient parallelization.
- 编辑距离为什么真的是『距离』:字符串上的自由幺半群与三角不等式Why Edit Distance Really Is a Distance: Free Monoids on Strings and the Triangle Inequality
- 问题:拼写检查要把『beleive 八成是 believe 的笔误』变成数学——也就是在全体有限字符串 Σ* 上定义一个距离,把纠错变成『在英语单词这个子空间里找最近的点』。Problem: spell-checking has to turn 'beleive is probably a typo of believe' into math — which means defining a distance on the set of all finite strings, so correction becomes 'find the nearest point inside the subspace of English words.'
- 结构层:有限字母表 Σ 上的字符串集合配拼接运算构成一个自由幺半群——结合律、空串 ε 是单位元、每个字符串唯一分解成字母。『长度』是这个幺半群到自然数(带加法)的同态:拼接的长度等于长度相加。对程序员来说,这就是『列表追加』那套结构的代数名字。Structure layer: strings over a finite alphabet Σ, with concatenation, form a free monoid — associativity, the empty word ε as identity, and every string uniquely factored into letters. 'Length' is a monoid homomorphism into the natural numbers under addition: concatenating lengths is adding lengths. For programmers, this is just the algebraic name for the list-append structure you already use.
- 定义层:把 d(u,v) 定义为『最少多少次插入/删除/替换能把 u 变成 v』。距离的三条公理里两条几乎是白送的:非负且 d=0 当且仅当同串(长度为 0 的编辑序列只能是什么都不做);对称性(把编辑序列倒着走仍是合法编辑,倒走不改变『最短』)。Definition layer: set d(u,v) = the fewest insertions/deletions/substitutions turning u into v. Two of the three metric axioms are nearly free: non-negativity with d=0 iff the strings are equal (the only zero-length edit does nothing), and symmetry (run an edit sequence backwards and it's still valid — reversal doesn't change 'shortest').
- 唯一要真干活的是三角不等式,而它的证明是『粘贴』而不是计算:把 x→y 的最短编辑序列接在 y→z 的最短编辑序列后面,就得到一个合法的 x→z 编辑,长度正好是 d(x,y)+d(y,z);而 d(x,z) 按定义是所有 x→z 编辑里最短的,必然不超过这个数。不等式从『最短』两个字节字节地掉出来——这是这类构造最干净的地方。The triangle inequality is where the actual work is, and the proof is gluing, not computing: concatenate the shortest x→y edit with the shortest y→z edit and you have a legal x→z edit of length d(x,y)+d(y,z); since d(x,z) is defined as the shortest of all x→z edits, it can't exceed that. The inequality falls out of the word 'shortest' alone — that's the elegant part.
- 为什么值得:证成『度量』之后,『纠错=选最近单词』才有几何资格,后续的概率模型(n-gram 拼写纠错)才站得住。Kun 还顺手留了个诚实的尾巴:map 是幺半群同态,filter 和 fold 算不算要读者自己探究(他承认自己原先就弄错过)——『写代码』和『抽象代数』在这里是同一件事。Why it's worth it: only once edit distance is a proven metric does 'correct = nearest word' earn its geometry, and the probability model (n-gram spelling correction) has something to sit on. Kun also leaves an honest loose end: map is a monoid homomorphism, but whether filter and fold are is an exercise for the reader (he admits getting it wrong the first time) — 'writing code' and 'abstract algebra' turn out to be the same object.
程序员随想Notes From Programmers
- 『UB 反正就 segfault』是错的:三个实际汇编输出打脸'UB Just Crashes' Is Wrong: Three Real Assembly Outputs That Disprove It
- 常见说法:『未定义行为(UB)反正最坏就是段错误,编译器也不会做什么奇怪的事』——作者直接否掉这个说法,用三条实际汇编输出说话。The common claim: 'UB is fine, worst case it just segfaults' — the author shoots this down with three real assembly outputs.
- 例子一:调用 `std::unreachable()` 之后,GCC 16 直接把后续函数体的机器码整块消掉了(函数没被调用也会被优化掉),因为编译器不需要保证 UB 路径上的任何行为。Example 1: after `std::unreachable()`, GCC 16 simply deletes the body of the following function from the generated code — because a compiler owes no behavioral guarantees on UB paths.
- 例子二:`int* ptr = nullptr; *ptr = 99;`——GCC 生成的指令写的是 0(不是 99)到地址 0,然后用 `ud2` 主动崩溃;99 这个数字根本没出现在生成的程序里。Example 2: `int* ptr = nullptr; *ptr = 99;` — GCC emits a store of 0 (not 99) to address 0, then deliberately crashes with `ud2`; the number 99 never appears in the generated program at all.
- 例子三:`ptr += 10` 再解引用反而被正常生成成『读/写地址 40』——不是因为编译器『检测出这不是 UB』,而是因为它对 well-defined 代码的语义之外没有任何义务,不同编译器(GCC vs clang)在同一行代码上给出完全相反的合理生成结果。Example 3: `ptr += 10` followed by a dereference is instead emitted normally as 'write to address 40' — not because the compiler 'detected' it's not UB, but because different compilers (GCC vs clang) can legitimately produce completely different, equally valid code for the same source line.
- 可以带走的判断:UB 不是『稍微危险一点的写法』,而是整段代码语义上失去定义,任何一行 UB 都让编译器有权做出任何事;『我知道它实际会怎样』不等于『它被允许这样』。Takeaway: UB isn't 'slightly dangerous style' — it's the entire program's semantics losing definition. Any single line of UB entitles the compiler to do anything; 'I know what it actually does' is not the same as 'it is allowed to do that.'
- 冷静推演 php2shell:为什么中流量站点其实打不中A Calm Walk-Through of php2shell: Why Mid-Traffic Sites Probably Can't Be Hit
- 已知条件:最好的 PoC 需要对同一个 PHP worker 进程发 4 个连续请求,同时还需要知道精确的 PHP 版本、OS 版本、架构。Known constraints: the best public PoC needs 4 consecutive requests to the same PHP worker process, plus the exact PHP version, OS, and architecture.
- 作者自己推演了一个『尽力而为』的攻击路径:先开 149 个连接去占满其他 worker(mod_php 默认 150 个 worker),再对第 150 个 worker 发 4 个请求;中流量生产环境通常有多个容器、多台机器、持续 bot 流量,这条路径要试很多种连接数组合。The author walks through a best-case attack path: open 149 connections to occupy the other workers (mod_php defaults to 150 workers), then send the 4 exploit requests to the 150th worker; a mid-traffic production setup usually has multiple containers, multiple machines, and constant bot traffic, so this path requires trying many connection-count combinations.
- 算账:50 种常见 PHP/OS 组合 × worker 数从 10 到 1010 的取值(约一千种)≈ 5 万次尝试;每次约 10 秒、同一时间只能试一次,等于多天穷举——而且大部分尝试会先耗尽站点连接数、变成自伤式 DoS,站方会开始封 IP / 上 WAF,而多数高流量站点本来就有 WAF 和限流。The arithmetic: 50 common PHP/OS combos × worker counts anywhere from 10 to 1010 (about a thousand values) ≈ 50,000 attempts; at ~10 seconds each, one at a time, it's days of brute-forcing — and most attempts would exhaust the site's connection capacity first, acting as a self-inflicted DoS that gets the attacker IP-blocked or WAF'd, while most high-traffic sites already run WAFs and rate limits.
- 结论:中/高流量站点实际很难被打中;真正可能被命中的是流量很小、没做 bot 防护、暴露版本信息、接近默认配置的站点——作者明确说这类站点『应该优先打补丁』。他 10-25 补的 update 恰好证实了这个分界:低流量站点的批量利用确实已经开始、手法和他描述的一致,而『中流量站点难以利用』的约束『仍然成立』。Conclusion: mid/high-traffic sites are hard to actually hit; the realistically vulnerable ones are low-traffic, no-bot-protection, version-disclosing, near-stock-config sites — and the author is explicit that those should patch first. His October 25 update confirms exactly that split: mass exploitation of low-traffic sites has begun, matching his description, while the constraints making mid/high-traffic exploitation unlikely 'still stand.'
- 作者的真正观点:不是漏洞不重要(该修就修),而是反对 AI 安全厂商把每个新 CVE 都渲染成『15 分钟内不修就开门揖盗』的营销叙事——『我想找回我的星期三』。The author's real point: the vulnerability is important (patch it), but he objects to AI-security vendors turning every new CVE into a 'patch within 15 minutes or the gates of hell open' marketing narrative — 'I want my Wednesday back.'
- 口语是想法的运动服:Paul Graham 写作的简单技巧Spoken Language Is the Athletic Clothing of Ideas: Paul Graham's Simple Writing Trick
- 观察:大多数人一旦开始写作,就会切换到一种跟自己跟朋友说话时完全不同的语言——句子结构变了,用词也变了(比如没人会在聊天里把『写』说成『pen』)。Observation: most people switch to a completely different register once they start writing — different sentence structure, different words (nobody would say 'pen' as a verb in a real conversation).
- Graham 举了一个让他忍不了的例子:一本历史书里把毕加索描述成『那位善变的西班牙人』(the mercurial Spaniard)——这句话放在任何真实对话里都会让人侧目。Graham's example that got to him: a history book calling Picasso 'the mercurial Spaniard' — a sentence that would raise eyebrows in any real conversation, yet people write whole books of it.
- 核心论点:书面语言更复杂、更正式、更疏远,这会让读者的注意力有理由走神;更糟的是,复杂的句子和华丽的词会给写作者一种『我在说很多东西』的错觉。Core claim: written language is more complex, formal, and distant, which gives the reader's attention permission to drift; worse, fancy sentences give the writer a false sense of saying more than they actually are.
- 一个反直觉的观察:越是难的话题,专家之间反而越用口语——因为越难的话题越不能容忍语言本身挡路;『口语是想法的运动服』。Counter-intuitive observation: the harder the topic, the more informally experts actually talk about it — because the harder the idea, the less you can afford to let language get in the way; 'informal language is the athletic clothing of ideas.'
- 可操作的写法:初稿照写,然后逐句问『如果我在跟朋友聊天,这句话我会怎么说』;诗歌和少数刻意使用华丽语言的散文是例外。Actionable method: write the first draft normally, then for each sentence ask 'is this how I'd say it to a friend?' — poetry and a few deliberately ornate prose styles are the exceptions.
- 『编程自动化了,愿景还没有』:antirez 区分 vibe coding 和 automatic programming'Programming Is Now Automatic, Vision Isn't (Yet)': antirez Distinguishes Vibe Coding From Automatic Programming
- 背景:很多人现在说『我是用 Claude 写的这个软件』,antirez(Redis 作者)觉得这句话本身是个误导——他把整个过程分成两种截然不同的东西。Setup: many people now say 'I wrote this with Claude,' and antirez (Redis's author) thinks that sentence is itself misleading. He splits the process into two very different things.
- 第一种叫 vibe coding:你用很笼统的话描述需求,LLM 基于训练数据和当次采样随机出活,你几乎不介入设计,最多事后说『这里不对』。这条路有价值,它在普及软件生产的门槛。The first is vibe coding: you describe what you want in broad terms, the LLM produces whatever comes out of its training data plus this particular sampling run, and you barely steer the design — at most you flag things that don't work afterward. That has value in lowering the barrier to software production.
- 第二种叫 automatic programming:你全程主导设计、架构、取舍(从『这个函数具体怎么写』到『这个模块该不该存在』),AI 只是把执行速度提上来——它写代码,你定方向。The second is automatic programming: you drive the design, architecture, and tradeoffs the whole way (from 'exactly how should this function be written' up to 'should this module even exist'), and the AI just makes execution faster. You set the direction; it writes the code.
- antirez 的核心论点:『编程现在自动化了,但愿景还没有』。他用 Redis 举例:Redis 在技术上没什么新颖(基本数据结构加网络代码,每个合格的系统程序员都写得出来),它真正值钱的从来是里面装的思想和取舍;所以即使代码是 AI 生成的,它仍然是『我的代码』,因为愿景是我出的。antirez's core claim: 'programming is now automatic, but vision isn't (yet).' He uses Redis as the example — technically, Redis was never novel (basic data structures plus networking code that any competent systems programmer could write); what it was always worth was the ideas and tradeoffs inside it. So even if the code was AI-generated, it's still 'my code,' because the vision was mine.
- 可以带走的判断:判断一段 AI 协作的代码是『vibe』还是『automatic』,看的是你有没有在开始前就已经想清楚『要做什么、为什么这样设计』——有没有这一步,决定了这个东西是不是你的。Takeaway: to judge whether an AI-collaborative project is 'vibe' or 'automatic,' ask whether you already knew — before starting — what to build and why it was designed that way. Whether that step happened is what determines whether the thing is actually yours.
哲学与生活Philosophy and Life
- 『baloney detection kit』:Sagan 留给普通人的怀疑论工具包The 'Baloney Detection Kit': Sagan's Skepticism Toolkit for Ordinary People
- 来源:Sagan《魔鬼出没的世界》(1996)里『The Fine Art of Baloney Detection』一章;Popova 把它完整展开并补充了大量 Sagan 自己的真实例子。Source: Sagan's chapter 'The Fine Art of Baloney Detection' from The Demon-Haunted World (1996); Popova unpacks it fully with many of Sagan's own real examples.
- 9 个正向工具(摘要):独立确认事实、让懂行的人对证据做实质辩论、'权威'在科学里最多算专家、多假设竞赛(能证伪哪个就证伪哪个)、不要过度迷恋自己提出的假设、尽量量化、论证链每一环都得成立、奥卡姆剃刀、可证伪性。Nine positive tools (in brief): independent confirmation of facts, substantive debate among knowledgeable proponents, 'authorities' in science are at most experts, multiple-working-hypotheses (falsify whichever you can), don't attach to your own hypothesis, quantify where possible, every link in an argument chain must hold, Occam's razor, falsifiability.
- 20 个常见谬误(摘要):ad hominem、诉诸权威、诉诸不利后果、诉诸无知、特殊豁免、乞题、只看有利样本、小样本统计错觉、误解统计、前后不一致、不相关结论……每个都配了 Sagan 当时举的具体例子(Nixon、Eisenhower、UFO、小样本『我已经连掷三个七』等)。Twenty common fallacies (in brief): ad hominem, appeal to authority, appeal to adverse consequences, appeal to ignorance, special pleading, begging the question, counting only favorable examples, small-sample statistical illusions, misunderstanding statistics, inconsistency, non sequitur... each illustrated with Sagan's concrete example (Nixon, Eisenhower, UFOs, 'I've thrown three sevens in a row').
- Sagan 的重点不是『怀疑一切』,而是:怀疑论本身需要被正确使用——他对『用这套工具去怀疑一切』和『不用这套工具』两边都保持警惕,工具是为了让『好想法』在竞争里活下来,不是为了让怀疑本身变成目的。Sagan's point isn't 'doubt everything' — skepticism itself has to be used correctly; he's wary of both 'doubt everything with this toolkit' and 'don't use the toolkit at all.' The tools exist so good ideas survive competition, not so that skepticism becomes its own purpose.
- 对普通人的用法:不需要懂统计或哲学,只需要在做判断前问一句『我能想到第二个假设吗?我能证伪它吗?』——这就是 kit 里最实用的一条。For ordinary people: you don't need to know statistics or philosophy — just ask, before a decision, 'can I think of a second hypothesis? Can I falsify it?' That's the most usable single tool in the kit.
- 跟八位同住人一起住了六年:一个 42 岁女性的 disconnection 解药实验Living With Eight Housemates for Six Years: One Woman's Disconnection Experiment
- 背景:作者 42 岁,在伦敦做智库研究,她和丈夫跟另一对家庭(共 8 位同住人)租了一栋联排别墅,已经共同生活了大约 6 年。Setup: the author, 42, works at a London think tank and has lived — with her husband and another family, 8 housemates total — in a shared terraced house for roughly six years.
- 她做这件事的理由不是浪漫主义式的『想要更紧密的社区』,而是她处理过的每一个政策议题——过度消费、信任瓦解、民主腐化、孤独、心理健康、照护、气候、住房——最后都指向同一个根:『彼此无法共同承担』(disconnection)。Her reason isn't romantic 'community building' — it's that every policy issue she researched (overconsumption, fraying trust, democratic decay, loneliness, mental health, care, climate, housing) traced back to the same root: an inability to bear each other, to share space, skills, and deep selves.
- 关键区分:她把『社区生活』跟修道院传统做类比,而不是跟合作社或共居创业做类比——重点不是共同做事的效率,是『彼此被看见、彼此照料』这件事本身。Key distinction: she likens communal living to the monastic tradition rather than to co-ops or coliving startups — the point isn't efficiency of shared work, it's 'being seen by and caring for each other' as an end in itself.
- 她描述的几个具体机制:共同决策(包括买房、分账、厨房收纳)会反复把每个人童年里没处理干净的东西翻出来;破裂和修复(rupture and repair)是刻意的练习——看到对方最糟糕、最防御性的一面之后,选择不走。Concrete mechanisms she describes: joint decisions (buying the house, splitting accounts, kitchen storage) repeatedly force each person to confront things left unresolved from childhood; rupture and repair is a deliberate practice — seeing each other's worst, most defensive side and choosing not to leave.
- 可以带走的判断:她不是主张每个人都该这样住,而是用 6 年的第一手数据回答一个问题——『非交易性关系』(不靠市场、不靠血缘、不靠浪漫关系维系的那种照料关系)是不是可以被刻意设计出来,而答案是她认为可以,代价比大多数人想象的更真实(房子差点交易失败、孩子做噩梦问『为什么我们不能自己住』),但值得。Takeaway: she isn't arguing everyone should live this way — she's answering, with six years of first-hand data, whether non-transactional relationships (neither market- nor kin- nor romance-based care) can be deliberately designed. Her answer: yes, and the cost is more real than most people imagine (the house purchase nearly fell through on the day; her youngest asked, at 4 a.m., 'why couldn't we just stay in our flat, us alone?'), but worth it.
工具角Tools Corner
- Easylang:浏览器里的 BASIC,零安装零门槛Easylang: A Browser-Bound BASIC, Zero-Install, Zero-Friction
- 问题:想教一个完全没学过编程的人写代码,最省事的方式不是下载 IDE、不是装语言运行时,是打开一个网页就能写。Problem: the lowest-friction way to show a complete beginner what 'writing code' looks like is not an IDE download, not a language runtime install — it's a webpage that already works.
- Easylang 刻意模仿 80 年代家用机的 BASIC 体验:语法简单、变量不需要声明、立刻能看到结果,而且整个 IDE(编辑器+运行+保存)就跑在一个网页里,不需要注册账号。Easylang deliberately mimics the 80s home-computer BASIC experience: simple syntax, no variable declarations, instant results, and the whole IDE (editor + run + save) runs inside one webpage, no account needed.
- 原创点:代码本身可以存成一个 URL 直接分享——别人点开那个链接,看到的就是你刚才写的程序,不用下载、不用安装任何东西。The original move: your code can be saved as a URL you can share directly — whoever opens that link sees exactly the program you just wrote, with no download and no install.
- 适合的场景:课堂演示、给完全的新手看『程序到底是什么』、快速验证一个小逻辑。不适合的场景:任何认真的项目(它刻意不是为此设计的)。Good for: classroom demos, showing a total novice what a program is, quick logic checks. Not for: anything you intend to keep, by design.
- Corgi:把所有 AI 编码 agent 的状态排成一屏Corgi: Every AI Coding Agent's Status on One Screen
- 背景:同时跑 Claude Code、Codex、Pi、OpenCode 好几个 agent 的开发者越来越多,但每个 agent 的状态(在干活/等你回复/完成/闲置)散落在不同的终端、不同的会话里。Background: more and more developers run Claude Code, Codex, Pi, OpenCode, and others at the same time, but each agent's status (working / waiting-on-you / done / idle) is scattered across different terminals and sessions.
- Corgi 的核心设计:把这些 agent 全部收进一个类 tmux 的界面,每个 agent 一格,格子直接显示当前状态(working / needs-you / finished / idle),以及该 agent 烧了多少 token。Corgi's core design: pull all those agents into one tmux-like screen, one cell per agent, each cell showing its current state plus how many tokens it's burned.
- 一个细节:它对 Ghostty 终端做了图像支持(需要 nightly 版),意味着 agent 输出里的截图可以直接内嵌显示,不用切到别的窗口。One detail: it has image support for the Ghostty terminal (needs nightly), so screenshots an agent outputs can render inline instead of forcing you to switch windows.
- 可以带走的判断:如果你同时开 3 个以上 agent 干活,这个『谁在等你』的一屏视图可能比任何单个 agent 本身都值钱——瓶颈通常不是哪个 agent 写得快,是你没注意到某个 agent 在等你输入。Takeaway: if you run three or more agents at once, this 'who needs you' one-screen view may be worth more than any single agent — the bottleneck is usually not which agent codes fastest, it's that you haven't noticed one of them is waiting on your input.
- Steal My Bitcoin:把 PHP 漏洞变成一场真人 CTFSteal My Bitcoin: A Real PHP Exploit, Turned Into a Live CTF
- 背景:php2shell(最近曝出的 PHP 漏洞链)之后,安全圈在争论『这个漏洞到底能不能被打中』——luitjes 的冷静分析(本期中『程序员随想』有一条专门讲)说中流量站点其实很难。Setup: after php2shell (the recent PHP exploit chain), the security community was arguing about whether it's actually exploitable — luitjes's calm analysis (covered in this issue's programmer section) says mid-traffic sites probably aren't.
- Steal My Bitcoin 的做法:干脆不再争论,直接把服务器开放出来——藏了一个约 $500 的比特币钱包,你能利用什么手段拿到它就归你,公开钱包地址,全程有日志。Steal My Bitcoin's move: stop arguing, just open the server — a ~$500 Bitcoin wallet is hidden inside it, and whoever can actually extract it keeps it, with the wallet address public and the whole process logged.
- 这个设计把『该不该相信安全通告』从一个信任问题变成了一个实验问题:不信任 AI 安全厂商的渲染,直接用『试一下』验证。The design turns 'should we trust this security advisory?' from a question of trust into a question of experiment: don't take AI-security-vendor hype at face value, test it for real.
- 可以带走的判断:这是把『安全通告』和『真实可利用性』脱钩的一个很干净的演示——以后看到类似『CRITICAL, patch now』的通告,可以问一句:有没有人做过这种『拿真金白银试试』的实验?Takeaway: this is a clean way to decouple 'security advisory' from 'actually exploitable' — next time you see a 'CRITICAL, patch now' announcement, ask whether anyone has run a real-money experiment like this to verify it.