Actual #curl rewrites in #rust (not by me)
https://daniel.haxx.se/blog/2026/11/17/actual-curl-rewrites-in-rust/
Actual #curl rewrites in #rust (not by me)
https://daniel.haxx.se/blog/2026/11/17/actual-curl-rewrites-in-rust/
@bagder
> I don’t believe in rewrites into any language. I believe in constant and never-ending polishing, iterating and refactoring.
I always had this tension between rewriting vs changing when working on an old codebase, even when everything was in my favourite language already (I worked on the XAPI project for 9 years)
What worked well:
* Refactor accumulated cruft: can it be done more simply, or in a more general way? (I like deleting code more than adding it)
* Try to understand *why* the code is like that even if it makes no sense, or looks completely buggy. "Chesterton's fence" principle. (maybe the code is correct, but for a use case you haven't even thought of, because it is not as relevant today as it was 10 years ago)
* Replace hand rolled code entirely with an upstream project that is better maintained for a specialized area (sometimes requires a small wrapper, and differential testing). Careful that the replacement is actually better.
* Use new language features that simplify code, detect more bugs, etc. I was able to once delete an entire module, because it was implementable in one line using the standard library now
* Drop support for features or configurations that noone used
Having said that, sometimes rewriting small modules to incorporate all the design evolution, and lessons learned *is* worthwhile: design a new module from scratch with a new internal API (not a drop-in, that limits the design space).
Have a clear goal (more robust, better performance, etc.)
Then gradually move callers that used the old module to use the new module and new API. Everything keeps working and building during this time. If something goes wrong it is also easier to find where rather than doing one big change.
At the end you have your (module) rewrite.
@bagder Shouldn't a meaningful Rust port be smaller than the C implementation? Would say that person just burned quite some money for nothing but entertainment and embarrassment.
@bagder I know the joke is (or was) why not re-write curl in Rust.
I would like to challenge you to re-write it in L∃∀N, which is transpiled to C and afterwards compiled with GCC to binaries.
> I don’t believe in rewrites into any language. I believe in constant and never-ending polishing, iterating and refactoring.
there is one instance where these converge
if a program is written in COBOL or Pascal, rewriting it in another language should be a part of the never-ending iteration. future maintenance will rely on that
figuring out when to switch languages is hard tho. i dont think c is at that point (unless a rewrite will guarantee more maintainers)
@bagder
A bit concerned for the direct use of the original project's name for even not a fork. A little bit impersonating
@nk that annoys me as well
@bagder I find the statement that Rust rewrites of curl would have 67 vulnerabilities misleading, not just because it buckets all "not memory safety" bugs into one category (ignoring other safety-relevant aspects of Rust such as the rich type system for instance with enums, the error handling story, the careful standard library APIs, etc. which _can_ be used properly to reduce the risk of bugs), but most importantly because I don't think AI slop 1:1 rewrites of curl are a relevant benchmark.
The benchmark should be actual established libraries with similar functionality as curl, such as https://docs.rs/reqwest.
According to https://rustsec.org/search.html?q=reqwest, there have been 0 vulnerabilities reported in it (this year and in general). Is it because of under-reporting of vulnerabilities, or is reqwest legitimately safer? One clear pitfall is that the Rust advisory database doesn't list vulnerabilities in transitive dependencies (indeed, rustls had 5 low/medium vulnerabilities reported this year: https://rustsec.org/packages/rustls.html). I think the honest truth is that the analysis is inconclusive. We can't claim that reqwest had 0 vulnerabilities discovered this year, but we also can't claim that it had 67.
One may argue that reqwest doesn't have feature parity with curl (I haven't checked), which would explain a lower vulnerability rate. But I think that'd be a very different story because it becomes a trade-off between more features vs. smaller API surface and security.
@gendx comparing with *something else* would be comparing apples to oranges IMHO. Impossible.
@bagder 8600 USD that could have been donated to the cURL team for further improvement and bugfixing.
@bagder Hi Daniel, while I'm fully onboard with vibe slop Rust rewrites being unhelpful, this statement doesn't logically follow, since judicious use of Rust's type system can prevent many more. I haven't actually evaluated the other vulns but it might be worth making this clearer in the post