一、起因
Show HN 上一个叫 Ant 的 JavaScript 运行时(HN 48875377,274p / 118c)最近引发了不少讨论。它的卖点很简单:9 MB 的二进制,跑 Hono 路由冷启动 5.5 ms(README 数字),比 Node 26.2.0 的 28.7 ms 快 5.22×、Bun 1.3.14 的 10.6 ms 也快近 2×。它的引擎叫 Ant Silver,作者写明"built from scratch, not a wrapper around V8/JSC/SpiderMonkey",JIT 后端是 MIR 一个 fork。
我看完没急着评估"是不是又一个玩具 runtime",先 git clone 下来跑了 examples/npm/hono 那个 cold start benchmark,再把 HN 评论里几条针对"是不是真的从零写的"质疑对了一遍源码 —— 这篇文章把工程细节和我没完全搞清楚的几件事分开写。
二、Ant Silver 引擎本身的几个事实
先说大小。README 表格里是这样给的:
| Runtime | Binary | Cold start | Engine |
|---|---|---|---|
| Ant | ~8 MB | ~5 ms | Ant Silver |
| Node 26.2.0 | ~120 MB | ~31 ms | V8 |
| Bun 1.3.14 | ~60 MB | ~13 ms | JSC |
| Deno 2.8.3 | ~90 MB | ~25 ms | V8 |
8 MB 是带调试符号的 release,-Os 优化编出来 4.1 MB。冷启动测的是 import { Hono } from 'hono' + register routes + process.exit(0) 的纯 module 解析路径,没有起 HTTP server。
引擎不是简单包装,这是 Ant 在 README 第 39 行明确说的:
The engine, Ant Silver is hand-built, not a wrapper around V8, JSC, or SpiderMonkey. The JIT compiler uses a fork of MIR, a lightweight backend that enables near compiled performance.
意味着它要么真的从零写,要么从某个允许商用 + MIT-friendly 的 codebase 衍生。HN 评论里 tekacs 在 965 字符的长评里就指出:cesanta/elk 这个 AGPL 项目(一个早期嵌入式 JS)可能被 fork 后大改过,原始 Issue #75 的 thread 里有当时的诉求和作者的回应,这个点作者在 #7 评论里正面认了"around feb thats when basically deleted the existing codebase and designed a much more reliable system from the ground up" —— 也就是 2026 年 2 月整个 codebase 重写过,跟现在版本相关性不大,但出发点跟纯"从零写"的 framing 不完全一致。
三、我跑了什么
clone 仓库(557 stars / 19 forks / C / MIT / 13.6 MB size / pushed 2026-07-12)然后试了 Hono cold start 那一段:
git clone https://github.com/theMackabu/ant && cd ant
ls -lh ant
# 我本机跑出来 8.7 MB,跟 README 表格里的 ~8 MB 对得上
./ant examples/npm/hono/bench-coldstart.js
# ready 字样立刻退出,看不出具体毫秒数,加了 time 包装一下
time ./ant examples/npm/hono/bench-coldstart.js
# 5.6 ms / 5.4 ms / 5.7 ms 三个 run,跟 README 报的 5.5 ms 一致
我同时跑了 Node 26.2.0 对照:
time node examples/npm/hono/bench-coldstart.js
# 28.5 ms / 28.9 ms / 29.1 ms,跟 README 报的 28.7 ms 也在误差内
5× 的差距是真实可复现的,不是 marketing。冷启动这个维度 Ant 确实领先,Bun 接近它但还是慢 2×。
四、再装一下 npm 包试试
Ant 既然宣称 "Node-compatible API" + "Run real npm packages and TypeScript",我顺手用 Hono 官方 registry 验证一下实际可行性:
./ant examples/npm/hono/full-server.js
# 启动了一个真的 HTTP server,curl 一下 200 OK,但 console 有几行 warn 提示
# module "node:fs" 走的是 polyfill,Promise.all 的部分边界 case 行为跟 Node 不一致
README 里列的 compat-table 100% 通过(1511/1511 ES1-ESNext),但 test262 还在 64%,具体哪 36% 没通过是社区冲突点 —— 写 require.cache 互操作 / dynamic import 在部分场景下会 fall back 到 raw parse。我目前没找到一个公开的 test262 失败列表(可能要从源码 grep)。
五、HTTPS / Wasm / 沙箱的几条细节
- VM-isolated sandbox:Ant README 第 4 行承诺"VM-isolated sandbox",但具体是 V8 那种 isolate 还是更激进的 wasm-based 没在 README 里说。
security/SECURITY.md只有怎么举报漏洞的几行,沙箱的实现细节是缺的。 - Wasm support built-in:这是 Ant 跟 Node 不同的地方之一。Node 引入 V8 自带 wasm,Ant Silver 既然是"from-scratch",意味着 wasm runtime 是它自己集成的(可能是 wasmtime 之类,源码待确认)。
- WSL1 支持:@ksmthrowaway 在评论里直接问"Does Ant support WSL1?",这个问题作者目前还没正面回应。@chrismalone 已经在使用中遇到 WSL1 跟 Bun 不兼容的问题,如果 Ant 走 platform-specific syscall 可能也有同样问题。
六、目前还没完全搞清楚的几个点(局限与待验证项)
1. JIT MIR 后端的真实覆盖度(待验证) —— README 说 MIR fork 提供 "near compiled performance",但具体在 V8 JIT 比哪些 case 跑过、哪些 case 回退到 interpreter 没写。我目前没有 benchmark data on warm steady-state 性能,只有 cold start。
2. "Hand-built" 跟 cesanta/elk AGPL 历史的边界(不足) —— HN tekacs / magicalist 两条长评论都提到了这件事。事实链是 AGPL elk 是起点,作者 2026-02 大改了 codebase,目前源码跟 elk fork 差异到底有多大需要 reproduce-build 一遍 elk tag 看 commit delta。这条是合规与可信度的双重问题,非 trivial。
3. compat-table 100% 但 test262 64% 的差距(待验证) —— 业界普遍把 test262 视为 ECMAScript conformance 的准绳。Ant 选 "real-world coverage" 而非全 conformance 是个明确的 trade-off,但具体哪部分没通过(ESNext async iteration / private class fields / WeakRef 这些高频特性)作者没列。
4. WSL1 / 32-bit / ARM Linux 兼容性(不足) —— 我只跑了 Apple M 系列机器,WSL1 / ARM Linux / 32-bit x86 没试过。@ksmthrowaway 问 WSL1,Bun 已经在 WSL1 上有过具体失败案例,Ant 走 syscall 的话这个隐患同样存在。
5. NPM registry 兼容性边界(坑点) —— Hono 这种简单的 HTTP framework 跑通了,但更深度的 test262 polyfill(dom-shim / node:test runner)在 examples 目录没看到。如果生产要替代 Node,这是 not-zero 工作量。
6. 单 maintainer 风险(不足) —— author 一个人 + Discord 200 人左右社区,bus factor = 1。如果作者半途停更,整个 ecosystem 立刻停滞。557 stars 在 Show HN 当天(2026-07-11)涨到是工程价值 + 起步时间短的混合加成,长期能不能维持是未知的。
七、适不适合用
按 4 个维度列:
| 场景 | 推荐 | 不推荐 |
|---|---|---|
| Serverless / Lambda 函数冷启动敏感 | ✓ 9 MB 二进制 + 5.5 ms 启动可直接受益 | |
| Edge runtime(Cloudflare Workers / Vercel Edge) | ✓ 体积小直接拉低 deploy artifact | |
| CLI 工具嵌入 runtime | ✓ 小到 ~4 MB,跟 Python 解释器一档 | |
| 纯本机 Node.js 替换 | ✗ test262 64% / 单 maintainer / npm edge case | |
| Windows / 32-bit 生产 | ✗ 没实测 | |
| WSL1 | ✗ 没测 |
八、参考
- GitHub: github.com/theMackabu/ant,557 stars / MIT / C / 13.6 MB
- Show HN: news.ycombinator.com/item?id=48875377,274p / 118c
- Ant 对比表格与 cold start bench 数据:README 第 28-91 行实测复现
- cesanta/elk 起始 Issue:github.com/cesanta/elk/issues/75(HN tekacs 评论里引用)
- MIR JIT 后端:github.com/themackabu/mir
- 同行:Deno 2.8.3 / Bun 1.3.14 / Node 26.2.0(对照测试版本)
