Actual curl rewrites in rust

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

For a long time we have received repeated requests for, or questions about, a curl rewrite in rust. Often as a joke, but also seriously. A joke from years ago In this modern world of AIs, we have only been waiting for someone to prove it possible and now it seems we don’t have to wait anymore. This fall seems to be the time of the curl-in-rust takes as we first saw urlx appear a few months ago, claimed to be a memory-safe, from-scratch reimplementation of curl and libcurl and now in November curl, rewritten in Rust – a rewrite of curl and libcurl in Rust. This second one confusingly enough not even using a different name. This latter one claims to have spent 8,600 USD to make it happen.

长期以来,我们不断收到关于用 Rust 重写 curl 的请求或询问。这通常是开玩笑,但也有认真的。多年前的一个笑话,在如今这个人工智能时代,我们一直在等待有人证明其可行性,现在看来我们不必再等了。今年秋天似乎成了“curl-in-rust”的爆发期,几个月前我们先是看到了 urlx 的出现,它声称是一个内存安全、从零开始的 curl 和 libcurl 重新实现;到了十一月,又出现了名为“curl, rewritten in Rust”的项目——即用 Rust 重写的 curl 和 libcurl。令人困惑的是,第二个项目甚至没有使用不同的名称。后者声称为了实现这一目标花费了 8600 美元。

Writing code once was never the issue Writing code once was never the big deal with software and it still isn’t. Sure, it’s fascinating that you can make a set of agents accomplish this in only a few weeks but let’s face it: it could do this because all the AIs of the world have trained on curl code for years. curl is extremely well documented, there are hundreds of existing open source application using its API and there are thousands of test cases to verify the implementation. The C code sits there and all the AI needs to do is convert it to rust, then polish until the tests work. A know-it-all person’s comment from years ago curl is the result of time curl has come to be what it is thanks to many decisions, lots of time, many users, oceans of feedback and many iterations. Sure, recreating what curl is at any specific single moment in time is certainly doable. Doable, because we have made a perfect specification for that project.

编写代码本身从来都不是问题。对于软件而言,编写代码从来不是什么大不了的事,现在依然如此。当然,能让一组智能体在几周内完成这项工作确实令人着迷,但我们要面对现实:它之所以能做到,是因为全世界的人工智能多年来都在 curl 代码上进行了训练。curl 有着极其详尽的文档,有数百个现有的开源应用程序在使用其 API,并且有数千个测试用例来验证其实现。C 代码就在那里,人工智能所要做的只是将其转换为 Rust,然后进行润色直到测试通过。多年前一位“万事通”曾评论道,curl 是时间的产物,curl 能有今天,归功于无数的决策、大量的时间、众多的用户、海量的反馈以及多次迭代。当然,在任何特定时刻重现 curl 的状态当然是可行的。之所以可行,是因为我们已经为该项目制定了完美的规范。

Behind already During the time these agents converted 185,000 lines of C code into 340,000 lines of Rust code (I counted), we merged over 300 commits in the actual curl project. We actually improved curl during these a little more than three weeks. A little over 200 bugfixes actually. 200 bugfixes that none of those rust rewrites have. We also fixed a few vulnerabilities. In another month we have done another 200 and maybe fixed a few more vulnerabilities. Will these clones keep up? The constant tweaking, fixing, improving and extending is what makes a software project live, what makes it attractive to users and what makes it able to compete with alternatives. That fixing, and occasional new feature, is a direct result of a working community of users, contributors and maintainers. That goes way beyond the source code or which language that is used.

已经落后了。在这些智能体将 18 万 5 千行 C 代码转换为 34 万行 Rust 代码(我数过)的时间里,我们在真正的 curl 项目中合并了 300 多个提交。在这三个多星期里,我们实际上改进了 curl,修复了 200 多个 bug。这些 Rust 重写版本都没有这 200 个 bug 修复。我们还修复了一些漏洞。再过一个月,我们又完成了 200 个修复,可能还修复了更多漏洞。这些克隆版本能跟上吗?不断的调整、修复、改进和扩展才是一个软件项目保持活力的原因,也是它吸引用户并能与替代品竞争的原因。这种修复以及偶尔出现的新功能,是用户、贡献者和维护者组成的活跃社区的直接成果。这远超出了源代码或所使用语言的范畴。

A primary reason it is hard to make a competing curl alternative is because of the development speed, the development team and the community around curl. It is not because of the chosen language it is implemented in. Only curl can boast decades of ABI and API stability and prove that we know this and can do it well – over time. An alternative that pops up today might be able to do it as well, and in a few decades we will know if they could. C I know I’m repeating myself but: out of the 81 vulnerabilities we have confirmed in curl so far during 2026, 14 were the result of mistakes that most likely would have been avoided had we used a memory-safe language such as rust. That’s 17.3%. A Rust implementation of curl would thus still have had 67 of those vulnerabilities.

制造一个能与 curl 竞争的替代品之所以困难,主要原因在于开发速度、开发团队以及围绕 curl 的社区,而不是因为它所使用的编程语言。只有 curl 能够夸耀其数十年的 ABI 和 API 稳定性,并证明我们了解这一点并能长期做好它。今天冒出来的替代品或许也能做到,几十年后我们就会知道它们是否真的能行。我知道我在重复自己,但还是得说:在 2026 年迄今为止我们在 curl 中确认的 81 个漏洞中,有 14 个是由于错误导致的,如果使用像 Rust 这样内存安全的语言,这些错误很可能可以避免。这占 17.3%。因此,一个 Rust 实现的 curl 仍然会有那 67 个漏洞。

No rewrites I don’t believe in rewrites into any language. I believe in constant and never-ending polishing, iterating and refactoring. Those rewrites I should add that I have not been in contact with any of the people behind these rewrites, and if there are two I bet there are more that I just haven’t seen yet. I only know of them because people have pasted me links to their repositories. I don’t know what they will do with those projects going forward. Are they anything more than proof of concepts? I presume we will find out. They can of course follow along our commits and convert them to rust on the fly if they want – we only do about 11 commits per day on average. Or maybe they ignore the bugreports or maybe they take their projects in other directions? I wish them good luck whatever they decide!

不重写。我不相信用任何语言进行重写。我相信的是持续不断的润色、迭代和重构。关于那些重写项目,我应该补充一点,我没有与这些重写项目背后的任何人联系过,如果现在有两个,我敢打赌还有更多我还没看到的。我之所以知道它们,是因为有人把仓库链接发给了我。我不知道他们未来会如何处理这些项目。它们难道仅仅是概念验证吗?我想我们会知道答案的。他们当然可以跟随我们的提交,如果愿意的话可以实时将其转换为 Rust——我们平均每天只有大约 11 次提交。或者也许他们会忽略 bug 报告,又或者他们会将项目引向其他方向?无论他们决定做什么,我都祝他们好运!

How do I feel about them? Several people asked me this. Imitation is the sincerest form of flattery that mediocrity can pay to greatness. / Someone I’m amused. A little puzzled. Fascinated. They spent their money and effort on that? I find it quite interesting. I couldn’t possibly be part of the “just rewrite it in Rust” crowd, but I also do see the benefits in many cases. It feels like, while ideally it’d be good to have that effort put into curl itself and see things improved and fixed, the fact that it’s a problem space people are paying attention to at all is a Good Thing™?. I hope something useful comes of them, just so we’ve got something interesting and novel to look at, at least. Maybe it leads to better understanding of the big wonderful world of internet transfers. I appreciate the hubris – you’ve gotta start with blind, cocky optimism sometimes. 😛

我对此有何感想?几个人问过我这个问题。模仿是平庸对伟大所能表达的最真诚的恭维。/ 有人说。我感到很有趣。有点困惑。着迷。他们把钱和精力花在那上面?我觉得这很有意思。我不可能成为“直接用 Rust 重写”那一派的人,但在许多情况下,我也确实看到了其中的好处。感觉上,虽然理想情况下,如果能把这些精力投入到 curl 本身并看到问题得到改进和修复会更好,但人们关注这个领域本身就是一件好事。我希望它们能产生一些有用的东西,至少让我们能看到一些有趣且新颖的东西。也许这能带来对互联网传输这个宏大而美妙的世界更好的理解。我欣赏这种狂妄——有时候你确实需要从盲目、自大的乐观开始。😛

Reply “81 vulnerabilities we have confirmed in curl so far during 2026, 14 were the result of mistakes that most likely would have been avoided had we used a memory-safe language such as rust. That’s 17.3%.” Nice, that sounds like very good motivation for a Rust rewrite. Something that is always missing from these post-hoc analyses is the changes and features that were never implemented because the language’s unsafety made it too expensive and risky (“that which is seen and that which is not seen”). A strong type system allows you to be much more scrappy and fearless.

回复:“2026 年迄今为止我们在 curl 中确认的 81 个漏洞中,有 14 个是由于错误导致的,如果使用像 Rust 这样内存安全的语言,这些错误很可能可以避免。这占 17.3%。” 不错,这听起来是进行 Rust 重写的一个很好的动机。这些事后分析中总是缺少的一点是,那些因为语言的不安全性而导致成本过高、风险过大而从未实现的变化和功能(即“看得见的与看不见的”)。强大的类型系统能让你在开发时更加大胆无畏。

Reply @Jesse: I disagree. What makes you “fearless” in development is A) a good architecture and B) a good test suite combined with C) good test and development tools. We have all that. We’re not holding back features because of the language. Never did. If there’s anything, we have too many features and we do too much. But hey, that’s what curl is.

回复 @Jesse:我不同意。让你在开发中“无畏”的是 A) 良好的架构,B) 完善的测试套件,以及 C) 优秀的测试和开发工具。我们拥有所有这些。我们并没有因为语言的原因而阻碍功能的开发。从来没有。如果说有什么问题,那就是我们的功能太多,做得太多了。但嘿,这就是 curl。

Reply > Nice, that sounds like very good motivation for a Rust rewrite. I agree; it is a good reason! But I fee

回复 > 不错,这听起来是进行 Rust 重写的一个很好的动机。我同意;这是一个很好的理由!但我感觉