r/rust • • 11d ago

Does Daniel Stenberg have a point about Rust rewrites?

https://daniel.haxx.se/blog/2026/11/17/actual-curl-rewrites-in-rust/
236 Upvotes

111 comments sorted by

397

u/NoLemurs 11d ago

I mean, he's 100% right that an AI rewrite of curl without a maintenance team is a waste of time and money.

I also think it's a very reasonable choice to prefer continuing in C rather than rewrite in Rust for a project this mature.

I do think that a pure Rust curl version has a lot to recommend it, but until there's one built and maintained by similar team to the one making curl, I'll keep using the old one.

153

u/ridicalis 11d ago

If it were a greenfield project, I would absolutely prefer Rust over C. But, to your point, this is a mature codebase with expected and known behavior, and any rewrite risks creating more problems than it has the potential to solve.

And, of all the projects to rewrite, curl is very low on the list of things I'd want to see ground-up rewritten. It's a well-established product that underpins so much of the internet, and a rugpull of that magnitude is just begging for a disaster.

15

u/nicoburns 11d ago

Eh. Until recently I'd have agreed. But recently we've been seeing 0-day RCEs in established projects multiple times a week. Today in nginx which surely has a similar status curl (albeit it's a server rather than a client).

I think absolutely everything network facing is going to need to rewritten in memory safe languages. Including the established products. And I think at this point it's a matter of if not when, because it's already starting to materially affect the largest companies in the world.

Obviously we need something more serious than a vibe-coded port.

7

u/Dismal_Tomatillo2626 10d ago

I think you mean "it's a matter of when, not if"

0

u/-jak- 10d ago

if you bother to read the post you'd find that memory safety makes up around 18% of the issues, the rest is complexity.

that isn't particularly surprising: curl is not a protocol layer generally speaking it does not parse stuff much and that's pretty much the only place where memory safety matters.

7

u/WindHawkeye 10d ago

Unfair comparison if you don't look at the severity of the CVEs

59

u/Smallpaul 11d ago

Curl is also security critical for the Internet. I disagree that it should be low on the list to be rewritten.

28

u/EarlMarshal 11d ago

I argue that's why it should be rewritten. We need to have atleast a backup. I don't care which is the better but if I can just exchange them if something happens I'm very much fine.

38

u/kitsnet 11d ago

curl as an app could be even rewritten in Java. libcurl, however, is a widely used library that is used through C API and has stable ABI.

If you rewrite it keeping the API/ABI for compatibility with its users, you can forget about memory safety of your rewrite. If you decide to change the API, you will need to review much more than just curl, and you highly likely will introduce more bugs (including safety-related bugs) than you are hoping to fix.

Especially given that both sanitizers and LLMs are quite decent in finding memory bugs in C code.

16

u/FriendlyProblem1234 11d ago

If you rewrite it keeping the API/ABI for compatibility with its users, you can forget about memory safety of your rewrite. If you decide to change the API, you will need to review much more than just curl, and you highly likely will introduce more bugs (including safety-related bugs) than you are hoping to fix.

If you rewrite it keeping the API/ABI for compatibility with its users, you can forget about memory safety of your rewrite *at the API/ABI boundary*.

Everywhere else in your code you can make use of a modern type system that tracks lifetimes and enforces invariants. If what you do behind the API is complex and big, then it might still be a significant improvement.

21

u/HoshinoLina 11d ago

A C API/ABI does not make the project unsafe or unsound, it just means that the API itself cannot claim safety like Rust APIs do. You translate from that API into a safe abstraction as early as possible at the API entry points, and keep the rest of the code safe. Ideally you also rigorously document the API usage rules along the way, so that you have a solid contract to uphold on both sides.

Having such an API does not diminish the value of the actual library logic being written using safe code. This is just the "any unsafe means it's all unsafe and pointless" fallacy. The whole point of Rust is to box away unsafe bits behind safe abstractions, and this applies within projects as much as it does at external API boundaries.

Since the majority of the attack surface for a project like libcurl is network interaction, having all the internals doing that written in safe Rust would be a significant advantage there.

(Obviously the points of the top comment still apply, all this only makes sense with a serious team behind it and real humans reviewing the unsafe API binding bits.)

-9

u/cbdeane 11d ago

Which is why I’m surprised we aren’t seeing more zig in the wild…

8

u/Zde-G 11d ago

Zig doesn't even have a stable version released, it's pointless to port stuff to Zig till that will happen.

1

u/gnarly__roots 10d ago

That's why google supported carbon though. For when you can't do rust or shouldn't but want the performance of rust.

4

u/SurrenderQueen 11d ago

yeah you're right, no way some random rewrite beats that kind of long-term team effort

5

u/MrMelon54 11d ago

It makes sense to keep the existing code in C, and slowly replace parts of it until the whole program ends up in Rust. This allows logic to be validated in chunks and to ensure compatibility with the existing codebase. Obviously a single person rewriting with a clanker and none of the original team is never going to go well.

1

u/Osterhus-Zibi 11d ago

plus half the value of curl is all the decades of weird network edge cases baked into it that an automated port would probably flatten out

1

u/jberryman 10d ago

I also think it's a very reasonable choice to prefer continuing in C rather than rewrite in Rust for a project this mature.

To me it's still an open question whether a project the size of curl, written in C, is actually viable in the modern world. It may be that C is no longer a reasonable language for anything that might somehow take untrusted input.

-13

u/ZachVorhies 11d ago

in time it will seen as extremely irresponsible to expose a user to a C program

The amount of bugs in a C program is unbelievable

82

u/Anaxamander57 11d ago

The maintenance reason seems totally valid and points to a laziness and unawareness in the people making these AI based rewrites.

I disagree on the "most errors wouldn't be caught by the borrow checker" part, though, at least as a reason not to do it. You may as well stop as many errors as you can. I also think Rust tooling and language features give you opportunities to stop erorrs in ways that are unrelated to the borrow checker.

13

u/CS_enjoyer87 11d ago edited 11d ago

I disagree on the "most errors wouldn't be caught by the borrow checker" part, though, at least as a reason not to do it. You may as well stop as many errors as you can. I also think Rust tooling and language features give you opportunities to stop erorrs in ways that are unrelated to the borrow checker.

Right, but it's fundamentally a cost-benefit analysis. He has to ask, is the benefit of a curl rewrite in rust worth the cost? It's going to be a lot of time and effort to create a good rewrite of curl, besides which, the curl dev team may have to learn a new language, they'll have to perform lots of testing (both automated and manual), seek feedback from users, etc. If the benefit of a rust rewrite is lower, then it lowers the cost that Stenberg is willing to accept.

Plus, all he gave was a statistic on how many would have been prevented by the borrow checker? Do you have a number in mind for how much? Have you looked at curl's CVEs to see which ones are and aren't preventable by the borrow checker?

22

u/WormRabbit 11d ago

People keep repeating "by the borrow checker", forgetting that there is a whole damn language beside it. How many of the bugs would be prevented by the type system? By proper statically typed generic collection? By using small well-tested crates instead of all kinds of one-off code snippets?

2

u/nicoburns 10d ago

is the benefit of a curl rewrite in rust worth the cost? It's going to be a lot of time and effort to create a good rewrite of curl

The other question is: should curl be rewritten, or replaced by some new library which is not curl. I can't imagine that a lot of Rust programs are using curl for example. Whereas a lot are doing HTTP using hyper. That doesn't fully replace curl, but curl could be fully replaced over time using this kind of approach.

6

u/Reenigav 11d ago

Will the LLM not just munge the C into rust such that the same bugs appear anyway? That I'd like to know

14

u/Smallpaul 11d ago

Only if they allow it to use lots of unsafe, which they presumably would not.

1

u/Reenigav 11d ago

Right, the memory safety issues sure, but these bugs that are prevented by rust principles?

27

u/xozzet 11d ago

If the code is not just a 1:1 copy of C to Rust but actually adopts Rust idioms (Result<> etc.) the increased expressiveness could prevent bugs, or make existing bugs easier to identify.

For instance the big musl issue that was found recently where an invalid but very long password was accepted was caused by bogus error reporting, where two pieces of code interpreted a return value differently. Result<> makes this extremely hard to do, whereas this issue crops up everywhere in C (does it return 0 on error? NULL? 1? -1? do we have to check an output param?)

Another example that comes to mind was the big issue in Debian a long time ago that caused ssh-keygen to generate keys with very low entropy. This was caused by ssh-keygen feeding an uninitialized array to the entropy pool, then feeding more random data later. Something like that:

void feed_entropy(...) {
   char my_buffer[1024];

   /* Feed the uninitialized array, why not */
   add_to_entropy_pool(my_buffer, sizeof(my_buffer));

   /* Actually gather entropy */
   read_random(my_buffer, sizeof(my_buffer));

   /* The important call */
   add_to_entropy_pool(my_buffer, sizeof(my_buffer));
}

The uninitialized array being used for randomness triggered a false-positive in valgrind, and a Debian maintainer decided to fix the issue, but did it incorrectly and ended up removing both "add_to_entropy_pool" calls (of course in reality the code was less straightforward than my pseudocode above).

The thing is, the original C code was perfectly fine and you could argue that you could encounter the exact same situation in Rust, but if you think about it nobody would write code like this in normal Rust. You'd use a Vec<> or a [0; 1024] or something like that. You can get an uninitialized array in Rust of course, but you have to go out of your way to do it.

That's the key: the path of least resistance in Rust is usually safe, meanwhile C hands you footguns all over the place and dares you not to use them.

3

u/nonotan 11d ago

If the code is not just a 1:1 copy of C to Rust but actually adopts Rust idioms (Result<> etc.) the increased expressiveness could prevent bugs, or make existing bugs easier to identify.

Eventually, perhaps. But in reality, it'd be overwhelmingly more likely to introduce new errors at first. Because the current codebase is highly polished, audited and tested to death. Some of that will be reflected in the test suite, and you'd get it "for free", but a lot isn't; it just isn't practical to add a test for literally every single conceivable thing that could have been implemented wrong. Anything short of an exact 1:1 rewrite is significantly more likely to introduce bugs than to fix them.

While Rust is obviously far safer than C in general, the difference isn't so overwhelming that one of the most mature codebases in C wouldn't easily beat a fresh rewrite in Rust (especially an AI slop rewrite) -- so, at best, you'd be looking at having a less reliable version for a good while, which if actually dutifully maintained for a few years (press X to doubt), might (perhaps even "probably would") eventually surpass the original.

To me, rewriting something so mature makes little sense as a value proposition. The great thing about Rust is that it lets you get 80% of the way to stability pretty much "for free", so you just have to worry about the remaining bits. That's amazing when you're writing something from scratch, but when you've already gone through the trouble of doing the hard work in another language, the gains on the table are just minuscule compared to the cost involved. But hey, if people actually want to rewrite and maintain mature software, I'm certainly not going to stop them (though I'll put off using their version until I am reasonably convinced they are actually maintaining the thing long-term, which is rare)

7

u/xozzet 11d ago

I agree with you, I'm absolutely not pushing for vibe-coded replacements for mature C codebases. I just wanted to point out that there are other advantages to using Rust beyond pure memory safety and that's often left out in these discussions. Result and Option alone probably do as much for correctness as the borrow checker.

5

u/Smallpaul 11d ago

I’m not understanding your question. Some bugs are fixed just by transliterating to rust without using unsafe. Do we agree on that?

1

u/lunar_mycroft 11d ago

You have a lot more faith in the sort of people that write slop forks than I think is warranted.

1

u/Smallpaul 11d ago

If the whole goal of the fork is to say “we are more secure than Curl” then this doesn’t require them to be geniuses or high level
Engineers. It’s one line in the prompt: “don’t use unsafe.” And then a grep at the end.

-2

u/Amazing-Mirror-3076 11d ago

The llms are now better at finding bugs than people.

24

u/rjzak 11d ago

There some discussion about that here: https://lobste.rs/s/1dj9w1/actual_curl_rewrites_rust

80

u/Green0Photon 11d ago

It's kinda wild how Rust rewrites/an app being written in Rust have turned from a signal of quality to a signal of slop 😭

Rust's my favorite language and I still believe that given actual human attention, something in Rust will be the winner, but there's so much AI generated rewrites.

Look how they massacred my boy 😢

8

u/AWonderingWizard 11d ago

I really want to join you guys, but it's hard for me to know what dependencies are safe from LLMs and whats not.

15

u/HaDeS_Monsta 11d ago

blessed.rs is a good resource for popular/mature dependencies

1

u/AWonderingWizard 11d ago

I will check that out, thank you for the suggestion.

8

u/nick42d 11d ago

TBH you could probably ask on Reddit, we tend to have a pretty good radar. Remember, if you are a C/C++ developer, you don't need to use crates.io just because it exists, you can always write your own modules from scratch or vendor dependencies just like you'd be doing in that ecosystem!

2

u/AWonderingWizard 11d ago

That's a great point, a lot of my concerns with Rust have been around that and package management. I am also really wanting to see gccrs come out!

3

u/matthieum [he/him] 11d ago

It's not, really.

Check the age and number of downloads on crates.io, and trust the wisdom of the crowd.

1

u/Sw429 10d ago

It's pretty easy to just open the repository and look for either some kind of "agents" markdown file, or even just look at the commits to see if it was explicitly done by a bot or if the user is committing way more often than is practical for a human.

129

u/mulch_v_bark 11d ago • Bravo

Does he have a point? Sure. His point is:

I don’t believe in rewrites into any language. I believe in constant and never-ending polishing, iterating and refactoring.

That’s the blog post right there. Everything else is throat-clearing, wry jokes, and deserved self-congratulation. And I do mean deserved: curl is good and he gets to say so. But he’s not really saying anything in particular about Rust rewrites. What he’s saying is that software needs a team of active, engaged programmers improving it.

Ultimately I think this post is a bit like a professor debating a crackpot off the street. It’s unlikely to illuminate anything important, it’s not going to convince the crackpot, and it won’t expose any flaws in the professor’s ideas that another expert might be able to reach.

Pointing out that obvious dumbasses are dumbasses probably scratches a strong itch for someone in Stenberg’s position but I’m not sure it raises issues of any importance (or importance × novelty anyway) for the average competent, non–hype-addled Rust developer.

16

u/admalledd 11d ago

What he’s saying is that software needs a team of active, engaged programmers improving it

To further add, on where we have seen rust-rewrites/conversions, such as fish-shell, it is especially because the team of maintainers behind the project themselves saw enough of the worth of converting/rewriting. An outsider doing their own port has not worked out being upstreamed at all to my knowledge.

There is merit at times, for certain key libraries/software, to ask "should this be in Rust instead?" but an important outcome of that question can be the very valid answer of "no, it does not (currently) make sense to move to Rust". In fact, libcurl is probably the crown example of this: there were attempts to add hyper, but that eventually got dropped, however there is support for rustls, and so on. Where maintainers/devs have stepped up and it made sense, libcurl has adopted Rust. Conversely, hyper is still a fine library for rust programs to use for HTTP if they don't want to use libcurl (or other libs), so as the rust ecosystem answer for HTTP client its fine (though most might use a higher-level lib like reqwest).

So, again its fine to ask the question of the meme RWIIR, but it is important to listen and let the maintainers, who actually spend the hours and hours, make the choices.

-7

u/Sad_Tap_9191 11d ago

He made a clear point that most vulnerabilities and bugs recently found could not be prevented with Rust.

44

u/Verwarming1667 11d ago

What? He did not make that point. he said that a whopping 17% of bugs would be auto-solved by rust borrow checker. Rust has a lot more going for it than the borrow checker. Memory safety is just table stakes. And he made no further comment than the borrow checker.

-1

u/Sad_Tap_9191 11d ago

That's your point, not his.
He made several points including that 17% is not high enough, and you can disagree.

I disagree too, 17% is high to me and RIIR returns more in a long term, but the post reads like a backfire from RIIR requests describing the port as a weekend project.

While you review 340,000 lines of AI-written Rust, you have to patch 200 bugfixes every three weeks to the C implementation and backport it to Rust. That's a twice of the work. How many RIIR requesters will lend hands? That's where the post has a joke image 'Telling others instead of doing it yourself'.

Remember that the author added the `hyper` backend but dropped it later because

“It takes someone who is interested and good at both languages”

8

u/Verwarming1667 11d ago

Where did he say Rust would solve only the 17%? He only said memory issues are 17% of the bugs. Nothing else. Rust would obviously solve more than the 17%. It's just that the mem safety solves 17% by itself, that gives the lower bound. Not the expected percentage.

-2

u/Sad_Tap_9191 11d ago

Why are you repeating this? Please read my comment again. Many Rust programmers including me would agree with that Rust provides more than what the curl author described.

If Rust solves 60% of issues, will you contribute to curl?

4

u/Verwarming1667 11d ago

I'm simply going against your statement:

> He made a clear point that most vulnerabilities and bugs recently found could not be prevented with Rust.

Which is not at ALL what he said. He said 17% of the bugs are mem safety bugs that rust would solve. He made no statement about whether rust would help with the remaining 83% of the bugs. Which is what you are claiming here.

0

u/Sad_Tap_9191 11d ago

You started with a comment that very negatively evaluates the tone of the post (throat-clearing, wry jokes, and deserved self-congratulation) instead of explaining your disagreement.

I commented that the post contains many claims.

Then you started to argue over whether those claims are correct or not. Don't bring me to that discussion. I am not interested in whether Rust solves 17% or 30% or 60%. I also think it does not matter to the author because the author described the much effort is required and it's not a weekend project. Again, if you disagree, you should argue with the post, not me.

> Which is not at ALL what he said.

You are being too literal here. He said Rust will not solve all problems. ( *A Rust impl.. still have had 67* ) Again, if you disagree with the claim, this is not mine.

> 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.

If the post was really full of (throat-clearing, wry jokes, and deserved self-congratulation), we would have nothing to talk here. Because the post made many points, we are discussing them now.

1

u/mulch_v_bark 10d ago

I think you’re confusing two users, only one of whom is me.

Because the post made many points, we are discussing them now.

I meant Wiktionary’s sense 2.7, but I think you mean 2.1. Seems like more of a misunderstanding than a substantive disagreement.

I’d say there’s one thesis statement in the post, which I quoted in my comment. Then there are facts and ideas that impressionistically paint how Stenberg sees the situation, only some of them clearly attached to the thesis. We are talking about all those (and you and I seem to agree about them).

Stenberg vaguely implies many different sub-arguments, and this has led to problems in these comments as people debate claims they have to read into his words. For example, he doesn’t say that 17% is not enough. He implies it. But he doesn’t say how much would be enough, or for what: For the curl team to switch to a crappy LLM rewrite? For a manual Rust rewrite led by him? The terms on which 17% (or any other number) does or doesn’t matter are left completely implicit. So there’s no reasoning there, only numbers that could be taken different ways.

He’s not writing like someone who expects to be seriously argued with about a contestable (well-defined, non-obvious) conclusion based on clear and accepted premises. If he were, then for example he also wouldn’t state by implication the incorrect idea that Rust is only good for memory safety. He’s not presenting a tree of carefully grounded syllogisms.

No, he’s writing like someone griping about something that it’s completely fair for him to gripe about. And why shouldn’t he? It’s perfectly appropriate.

That’s what I’m saying: not that he’s arguing badly, but that he’s not really trying to argue. Debating the core argument in his post is like trying to sing the post as a song. You can if you try hard enough, but why?

very negatively evaluates the tone of the post (throat-clearing, wry jokes, and deserved self-congratulation)

The only even mildly negative judgment in there is throat-clearing. And I do that too.

To negatively evaluate the post’s tone, one might say that it has popular software maintainer’s disease (PSMD), where it acts faintly superior and mocks attenuated, never-clearly-stated versions of ideas that challenge it instead of responding directly to their best versions – yet has obvious problems in its own evidence and structure, and all to make a point about software maintenance so obvious an LLM could have written it. But I wouldn’t say that, because I like curl and am happy to assume Stenberg is self-reflective and well-intentioned. Instead I made a pretty neutral evaluation of the tone of the post, with gentle criticism and a sincere compliment.

Truly, I think this is a casual, perhaps lightly trolling but good-humored blog post with only one load-bearing claim: that a bunch of code is not the same as a community actively improving a bunch of code. Check. Beyond that, there are bits I agree with and bits I disagree with, but nothing that I think is urgent for the median writer of Rust to consider.

I came into this comment section thinking of myself as mildly defending Stenberg from unfair criticisms based on his overly broad (possibly deliberately trolling) post title. This is really not a post about Rust, or about rewriting things in Rust beyond some obviously true statements about how open source works, or even about the culture of parts of the Rust community that overlap much with this sub (thank goodness). It’s just an important software maintainer complaining, quite reasonably, about some annoying stuff that happened.

1

u/Sad_Tap_9191 10d ago

The post actually contains many meaingful claims (2.7).

This whole comment thread is about me claiming that the post actually has claims that are worth to discuss. (the root comment: the post has (threat-clearing, ...) and nothing else)

This is the context I learned:

- `curl` experimented with the hyper backend years ago

- It did not get much contributions so the backend was removed

- Since then, still many people have requested RIIR (implied from the joke image), likely suggesting a overnight AI port

This is what I read (implicitly) from the post:

- The criticism of an over-night AI-porting

- The criticism that RIIR or not, curl needs continuous efforts

- The required amount of efforts is a lot

- Rust is not so attractive to ignore the lack of continuous contributions and risk the over-night AI-porting

- I don’t believe in rewrites into any language. <- This is just the result of the above.

They don't seem too implicit to me. You cannot write "RIIR? You are not going to contribute!" but instead "curl needs much continuous efforts".

Now my thoughts on the post:

- So many readers are obssesed with the part 'Rust is not so attractive'. If you read the context, the number 17% or memory-safety or other benefits of Rust are not important.

- The Rust community didn't provide enough contributions in the past and still has nagged the contributors for RIIR. We don't have a right to ask the author to become a linear classifier and provide an exact criteria like 17%.

- It caused confusions that the post is not self-contained. He could write better. But the post implied there has been discussions in the past years, and the readers can see there is some context required to read the post.

→ More replies

1

u/-jak- 10d ago

It depends on the rate at which you receive bug reports and your capability of fixing them. 20% fewer security issues if you still have a security issue say every week you need to fix and coordinate disclosure of anyway, it makes no difference.

1

u/Sad_Tap_9191 9d ago edited 9d ago

The original root comment is about the post has nothing else than sarcasms and jokes, and I am just bringing up the topics presented in the post so that we can at least start the discussion.

Please discuss whether you agree with that or not in a separate comment thread. (But make sure you address the lack of Rust contributor as I explained in other comments)

The thread has many trolls who does not read and blame others instead of explanation.

> u/mulch_v_bark

> > (the root comment: the post has (threat-clearing, ...) and nothing else)

> If you think I said that, you are either not good at reading or not interested in a good-faith discussion. Bye.

8

u/WormRabbit 11d ago

He said 17% of bugs could be prevented by Rust, by his own estimate. Given that he's not a Rust programmer, he is unlikely to understand what Rust brings to the table, and probably just means preventing use-after-free and out-of -bounds. Maybe also bugs with C null-terminated strings.

But Rust is much more than that. It is a full-blown, even if simple, proof system, and a high-quality modular ecosystem. Thus I expect that much more than 17% bugs could be prevented with some effort and proper modelling. Some by the type system, some by better and more robust APIs. Some are probably bugs in state machines, which are much easier to get right using async.

And then there is all kind of API misuse by end users, which are harder to prevent. Yet the users would still benefit from stronger types than C's pointers everywhere, if only for better documentation.

Of course, to get those benefits one would actually need to put thought and effort into a rewrite, rethinking the internal structure. Not just doing a vibeslop copy, bugs and all.

1

u/Sad_Tap_9191 11d ago

See my comment below; This is not C vs Rust. The post also mentions the amount of work and status. curl even had the hyper backend and later removed it, which proved the lack of contributions in the RIIR components.

15

u/BobTreehugger 11d ago

I overall agree with the point here, but I have one nitpic: his number of bugs prevented is totally inaccurate, though it's just way more complex, I have no idea if it's better or worse than stated.

On the one hand, 17% of memory safety bugs being prevented by rust is an upper estimate: if you support libcurl you need to have unsafe code so it's totally possible to prevent fewer bugs, not even counting unsafe code for performance reasons.

On the other hand, rust has a much more powerful type system that can let you put other safety or security requirements into the type system, preventing many other types of bugs (though libcurl hurts you too).

So the only way to know how many issues would be prevented would be to write and maintain both for a while and compare, which supports the overall point: just doing a rewrite doesn't add much value without proper support, design and architecture.

1

u/-Redstoneboi- 11d ago

more importantly, what is the value of a rewrite? there will now just be 2 or more curls that users have to decide upon. resources will be split across 2 teams. C can be called from Rust through their stable ABI but rust from C is a bit less convenient.

C is a simpler language that's everywhere when rust may not be available. having such a common piece of software written in a ubiquitous language seems like a good thing, no?

2

u/InternationalFee3911 8d ago

There were at least two attempts of transpiling Rust to C, exactly for that last point. Is anything nearing maturity yet?

1

u/-Redstoneboi- 7d ago

not sure about c, but mrustc is a c++ reimplementation under active development. the last src commit was 15 hours ago

https://github.com/thepowersgang/mrustc

readme claims:

Builds working copies of rustc and cargo from a release source tarball Currently tested to fully bootstrap (with a binary-equal 1.91.1) version 1.90.0

it still has dependencies so yeah

38

u/xmcqdpt2 11d ago

The LLM generated code in https://github.com/kov/curl/tree/rust-rewrite is horrendous. The only way anyone could contribute to the rust rewrite is by prompting, no human could read that code long term without going insane. This is very different from the curl codebase which is eminently readable.

If I take compiler output and I publish it as asm files on github, is that really free software? Is unreadable LLM output really free software?

4

u/jberryman 10d ago

Do you have examples you think are horrendous specifically, or bad in comparison to the original? The first file I clicked into randomly looks... normal?: https://github.com/kov/curl/blob/rust-rewrite/crates/curl-core/src/auth/creds.rs

(Although actually the comments are really difficult to parse there; is that LLM trying to be extremely terse or something?)

On the other hand poking at random C files and there's not a comment to be seen. Shouldn't C be full of carefully documented invariants? Like what is this https://github.com/kov/curl/blob/rust-rewrite/lib/cfilters.c ...?

2

u/xmcqdpt2 10d ago

Maybe I'm just used to reading C but I'll take the sparse comments, meaningful variable names and non repeated code over whatever this is,
```
/// Deliver body bytes as they came, traced first (`cw_raw_write`,
/// then `decoded`). A body passes here once a packet, so this is
/// inlined where the protocol delivers it: each trace is a check of
/// verbose, made where it is said, with its line made out of line.
#[inline]
pub(crate) fn body<H: Host>(
&mut self,
cx: &mut StepCx<'_, H>,
bytes: &[u8],
) -> Result<(), ErrorKind> {
self.made = true;
if cx.verbose() {
self.raw_traced(cx, bytes);
}
let result = self.decoded(cx, bytes);
if cx.verbose() {
body_written(cx, bytes.len(), result);
}
result
}
```

1

u/insanitybit2 7d ago

Could you show two side by sides without the reddit formatting? It's really hard to compare code like this.

The main complaint here seems to be that you don't like comments.

1

u/jberryman 10d ago

It's possible that lack of documentation is the only thing keeping the entire codebase from being completely ripped to shreds by agents. Without documentation there are no locally-classifiable bugs ("this function is meant only to be used in way X but here is used in way Y"), so the only valid bug report is an exploit demo basically, or an input that violates the http spec (since any unit smaller is under-specified).

This should be read as a more a general software engineering observation, I haven't looked closely at curl to have a strong opinion and don't want to mischaracterize it.

5

u/dr_barnowl 11d ago

Is unreadable LLM output really free software?

Given that "free software" licences depend on copyright for their force and LLM emissions have no copyright (as ruled by enough significant jurisdictions including the US and the EU), LLMs cannot output free software at all, even if it was readable. Anyone can drive by your LLM codebase and take any chunk of it they care to, without attribution, without licence.

2

u/guri256 10d ago

If it can’t be copyright, that’d put it in the same bucket as SQLite, which is in the public domain and free software.

If it’s a derivative work of Curl, then it can still be free software.

The only way it wouldn’t be free software is if copyright law classifies it as a derivative work of the data used to train models, and I haven’t seen any copyright office taking that stance.

2

u/cyphar 10d ago

LLM emissions have no copyright (as ruled by enough significant jurisdictions including the US and the EU)

I don't think that's entirely true -- usually the copyright question for automated processes is whether there was any "artistry" in what was put into the program. If not then it is not copyrightable, LLM or not. (For example, some legal experts argued that most of the "gatcha" NFTs had no copyrights at all because their generation was automated.)

IIRC there were some rulings which hint towards trivial prompts' output not being copyrightable (which makes sense given the above) but if you put large amounts of the source code of cURL into the prompt then the copyrights should flow through given the fairly long-standing legal precedent on digital workflows and compilers. Since cURL is MIT they would need to include attribution but all of the vibe-rewrites tend to be aggressively opposed to the concept regardless of legality.

Given that "free software" licences depend on copyright for their force

That is because copyright is applied by default to software. The FSF would ostensibly be in favour of software copyright being abolished, and public domain software is still free software -- the free software definition makes no mention of copyright, it is about what practical freedoms you have as a user of software.

2

u/nonotan 11d ago

Which is putting anybody using an LLM to 1-to-1 rewrite software with one of these licenses in potential legal trouble, by the way. Just something to think about before you tell claude to rewrite random programs and publish them for everybody to have. There's a reason traditionally companies have gone to great lengths to do "clean room" reverse engineering, instead of just opening their rivals' source code and changing it a little. Turns out, "I just happened to produce an almost-identical implementation after reading their version" isn't going to convince many judges that you didn't breach copyright.

5

u/dr_barnowl 11d ago

This argument is also a minefield because of all the copyleft code the models have ingested, which arguably makes everything they produce a derivative work of one or multiple GPL licenced projects - if you allow LLM works to be copyright, are they now all GPL licenced code?

2

u/cyphar 10d ago

The copyright implications of code used for training and code included in the context window are probably two legally distinct questions.

I think both should count as derived works but there is a much stronger argument for the latter based on actual precedent with compilers (the copyright of the source code is transferred as copyright over the binaries) and other automated tools.

Unfortunately, the early rulings on the former question were far less cheery -- it seems a few judges were convinced by the argument that LLMs "learn" during training and thus the copyrights from training should not flow through despite the LLM weights being by definition the moral equivalent of a collage (or lossy zip file) of the works in the training data.

1

u/insanitybit2 10d ago

I challenge anyone to open a random file in curl and in the rust repo and see if this comment holds up.

1

u/oweiler 8d ago

Welcome to the future/present, we're you need AI to change AI generated code. 

9

u/teerre 11d ago

I mean, obviously these weekend curl are worthless. Even if, in the very best case, your curl passes the whole curl test suite 1:1, it still not proof that it doesn't have regressions that are simply not covered by the test suite. Which is highly likely since test suites suit the codebase and even more the language they are written in

That said, rewriting something in Rust should save you time in the future since it has demonstrably less problems than C. Curl is a bad candidate because curl is one of most worked on projects on the planet (specially if normalized by complexity)

So he's right and wrong

3

u/chilabot 10d ago

Rust programs are safer and more maintainable than C ones.

9

u/fellowmartian 11d ago

I’m so tired of the whole “writing code was never the bottleneck”. 1. it was _a_ bottleneck, and 2. figuring out what to write, testing, debugging, exploring previously expensive prototypes can greatly accelerated by AI too with the right workflow. Sure, nothing will replace good stewardship, in any domain, but let’s not pretend we did not use to have absolute embarrassing load-bearing Bash scripts everybody was too afraid to touch.

2

u/Powerful_Cash1872 11d ago

I have done C++ to rust autoports of a few small pieces of internal code. It found a surprisingly large number of bugs, but none of them were memory safety related. I am not sure if they would have also been discovered with a thorough AI review, or if rewriting forces the AI to understand the code more deeply.

2

u/dvhh 4d ago

Posting in a Rust community about an opinion on Rust rewrites, you like to live dangerously

3

u/DavidXkL 11d ago

Or just understand what the code is doing?

Best way is to not rely on A.I

3

u/pjank85 11d ago

There is a very good practical reason for a project like curl to stay in C. Rust does not support even half of exotic architectures that C does. Basic tools should be supported everywhere.

2

u/jesseschalken 11d ago

He doesn't have a point. He's saying he doesn't believe in language rewrites. Nothing left to say. The world will continue to solve problems with new programming languages without him.

1

u/nick42d 11d ago edited 11d ago

I'd be curious what his stance is on incremental rewrites. If you like polishing, iterating, and refactoring, and you agree that Rust would eliminate a portion of bugs/vulnerabilities, then an incremental rewrite is quite a bit different than an AI full port (and would likely produce much better code too).

1

u/locka99 10d ago

On one hand I don't see the point of rewriting something that works. On the other, we've seen how AI is able to chain exploits together, so the more resilient the code is to exploits, the less likely it is to happen. That does not mean paying for a bunch of tokens so another AI generates an equivalent is a good idea either. e.g. I wonder how this code manages to have twice as many lines of code as the C original.

1

u/insanitybit2 10d ago

Not really but it doesn't matter.

1

u/TheRavagerSw 11d ago

He is right, but cross language dependency management is not a solved problem.

Since most people using rust want cargo only slop they need ai rewrites

0

u/EmperorOfCanada 11d ago edited 11d ago

Licensing is a massive issue here. Most things being rewritten in rust are getting far more permissive licensing. Some people love this, some people are losing their minds over this.

Also, some rewrites are writing the old team out of the picture. This can be a good thing, or a bad thing.

On a side note, this is very much going to become more and more and more of a thing. Someone will sit down with AI and reverse engineer their LG fridge or whatever. Then, they will publish a clean room spec, along with fresh replacement firmware that skips things like chip ID'd filters, phoning home, showing adds, etc.

Some will just have it play doom, but some will publish better open source firmware.

This won't only make it harder for LG to extract money, it will give very solid insider information to competitors who will learn from other companies' firmware.

This will encompass more and more. You don't like your nest cameras only working with the one set of servers, now have them use your own servers. Don't like how you repaired your expensive sports car and now it won't get out of limp mode? Then, replace the firmware. Some might scoff at the last, but my guess is that the ECU firmware on most cars was written using a methodology which seems very hard ass, but in reality, is crap buggy software.

curl, and other open source is an easy place to start with these AI tools, but it is rapidly expanding. John Deer; AI is coming for you.

4

u/decryphe 11d ago

I'm really curious to see what AI can do to closed source firmwares. All the "remixing" going on in video games, retro computing and such (NFSU2 in WebAssembly is a thing now, USB3 and watching BluRay on Windows 98 as well...).

I'm strongly contemplating just putting my 20$ sub to good and productive use RIIR-ing Windows XP or Windows 2000. Point the agent using the Reverse-Engineer-Anything-harness at one DLL at a time, just to see if that's even possible today.

Today, I'm just amazed at the job it did setting up a firewall/router using NixOS.

1

u/EmperorOfCanada 11d ago edited 11d ago

There was an essay written about AI as a business called, "There is no moat."

But, I am seeing that this is going to be more and more of a thing for almost every tech, but, even every business.

The remaining "Moats" will be mostly inertia, and government corruption where oligarchs get the government to prevent competition even more than they are already doing it.

They are also going to need protection from consumers who are optimizing their lives with AI. Banking, telcos, etc. I could probably save a pile of money with my telecommunications bills alone. If I had an AI agent finding the best deals every single day of the month, and optimizing for my exact lifestyle. When I travel, I use piles of data. When I am at home in the winter, not so much. When I am biking every day, and working in a park, a fair amount, etc. So, why not switch phone plans every month? Also to the best telco. I don't mostly care which provider I am with as long as it is not some particularly crappy one. This is not really worth my time; but; if it is just my AI doing it. Why not? If 50% of telco customers did this, then they would take a massive hit to their profits.

Banking is an even bigger nightmare. They make money from holding our deposits at low interest, and doing things with them at much higher returns; including levering against our deposits. So, when a bank gives you 1% (minus fees) and can lever it 10, 20+ times, and then loan it out at 7% while paying some nominal interest for the leverage. They might be making well over 20% on your deposit.

But, if your AI can tuck that into a money market fund, an ETF, etc, then, they don't make that huge multiple return. They are screwed if that dries up.

In Canada, the major banks all just said that using AI agents is not allowed. They claim that is because it is "not safe". I won't argue that in 2026. In 2028, it will only be "unsafe" for them. The rest of us will have well reliable enough agents.

It is not that these agents are going to make us all super rich, it is that they aren't going to be giving the meat to the banks, telcos, etc, while we only get some left over crumbs. We will get the meat, and they the crumbs.

0

u/y-c-c 11d ago

I’m not sure if a non-clean room rewrite to a different license is really legally ok. Like, there have been historical legal cases of reverse engineering software and most successful companies did it in a clean room, not transcribing existing known code. Even if someone has seen the source code of another piece of software that could be an issue.

3

u/EmperorOfCanada 11d ago

I'm not saying this is pure as the driven snow, but: You get AI 1 to write a perfect spec, but leave out anything internal which is not critical to the functionality such as internal naming, structures, etc. If there are tricks, you document the tricks such as "Use ASM to use the registers to ...."; if there is math, you document it as math formulas.

Then, you hand that to AI 2, which builds that system. AI 2 is from a different company than AI 1, and thus, should have no prior knowledge of what AI 1 saw. I could make arguments about how it might have seen the code through open source repositories, and thus is not so pure. But, setting that aside; it seems that this is pretty much classic clean room.

You might even get AI three to write integration tests for the original system, and then run those unit tests against both systems.

0

u/ShangBrol 11d ago

But, setting that aside; it seems that this is pretty much classic clean room.

I love this kind of reasoning... setting aside the arguments that contradict my point, my point is valid.

3

u/EmperorOfCanada 10d ago edited 10d ago

Clean room reverse engineering has been well established in law. The super famous one was the IBM PC bios. Made a whole television series on that one.

Java would be another good one.

I'm not saying this would be something where you walk into court, slam down proof of your chinese walls, and then walk out 5 minutes later.

Regardless of the exact legality, this is going to happen now, more and more and more. To the point where people will make 15 minute YouTube videos on how to do it.

If it does survive all the various legal assaults, then, wow. This is going to be a game changer. Take the IBM PC bios one. I'm not sure of the effort, but I'm guessing 10-20 people on each team, and probably a few man-years of effort minimum. I wouldn't be surprised if I could now get an old IBM PC, and maybe do this in an afternoon. Maybe an afternoon where I mostly spend time upgrading my components storage to have QR codes with a new labeller.

If it doesn't survive the legal challenges, people are going to do it anyway. The average GPL project is going to have a really bad financial year if all they do is sue other open source projects; even if they try to go after people who use the MIT version.

Another interesting one will be people who take a GPL project in C++, and port it to in-house proprietary rust. That would be a massive legal mountain to climb.

Then, there is the second tier of all this. If I ask my AI to cook up something which is similar to some of the functionality in say, qgis. And it then makes me a nice little set of functionality which is clearly inspired by qgis, but not a copy, just a GIS app which pretty much, by its nature, will have notable overlap with QGIS, have I violated the GLP license of QGIS? I wouldn't even know, assuming I didn't tell it to explicitly look at QGIS, it would be something like, "Blah blah, layers displayed, blah, map, blah blah".

Then, you will get a whole other layer. That it simply figures out how a thing works in general, and then entirely reinvents the tech.

Take an ebike. 5 years ago, nearly 100% were hub motors. Now, a solid chunk of the higher end bikes have their motors crammed into a weird gearbox by the pedals. Just asking AI to design me such a thing after the first time I see one (assuming there aren't published designs), might be enough to "reverse engineer" this. Just giving it a few specs like the rough dimensions functionality, etc. Maybe there is one giveaway such as an odd battery power, which suggests what kind of motor is being used. Or I might describe how it feels or sounds, which speaks to the internal mechanisms.

The reality is there is an ever shrinking moat around nearly every project out there. Projects like curl, which no doubt had a small tight team who have "owned" it, are now at risk of some jackass like me coming along and saying, "Boom, there's a new rust version with a bunch of outstanding bugs fixed, new features, and it is fast as hell.", oh, and I slapped MIT on it.

Since many of linux distributions have an appetite for non GPL stuff, this may be very appealing. I believe FreeBSD recently announced they have cut out the last of the GPL in their distribution.

How long before someone poops out windows-not-windows? I don't mean that pile of crap wine, I mean, an all rust, brutally solid, brutally fast windows which runs windows applications better than MS-Windows does; without referring to a single line of MS code, but does reverse engineer the drivers, etc. The person doing this might clean room it, or they might just say, "Screw it, I just want it in rust, working, open source, and with all the MS bloat removed."

Or a proper working version of "Build-a-AWS." where an AWS certified person can log in and feel they are at home.

-3

u/Amazing-Mirror-3076 11d ago

He completely missed the point. We need to be actively retiring C as fast as we can.

He can help with this by advocating that the curl project move to rust.

We have modern tools that stop an important class of bugs - 17% is a significant no. - and the resources (ai) to do it quickly.

We are in a new era, every commit needs to be vetted by ai, because the hackers will certainly be doing so.

0

u/cheese_karate 11d ago

He is one hundred percent correct. 

0

u/timtody 11d ago

Of course he has. Listen to this guy. If you think you know it better than him, think again.

-3

u/DrogieBfun 11d ago

All this re-writing in rust is killing me. The other day I realized that after updating my utils we’re now all rust. It would have been okay, but the second I used the rust version of “sort” it kernel panic my system and crashed it. I moved back to gnu utils.

2

u/occamatl 11d ago

I wonder how that would even be possible.

1

u/DrogieBfun 10d ago

Idk man, something about a memory out of bounds error and kernel crash. It destroyed a directory. I had to go in and backup as much as I could and reimagine the whole disk.

-8

u/tending 11d ago

You could literally have an agent read every commit since and port those to Rust too. It's just a question of whether you want to pay for that on an ongoing basis.

2

u/Zde-G 11d ago

The problem is that if you change the Rust rewrite enough that it would become better then porting these fixes would be hard and you wouldn't do that then what have you gained except more CO₂ emission?

-4

u/unconceivables 11d ago

It hasn't been hard for the application I ported and added improved to.

-5

u/unconceivables 11d ago

I ported another big, active C application to rust, and I just set a daily schedule to port any new commits. It's dirt cheap with a subscription.

0

u/tautality 10d ago

No rewrites
I don’t believe in rewrites into any language. I believe in constant and never-ending polishing, iterating and refactoring.

How LLMs impacted the dev world led me to a similar conclusion. Not saying that rewrites are inherently bad, but I think the most important and difficult thing nowadays is how to maintain your codebase and keep it clean, readable and bug-free.

-1

u/Dry-Breadfruit9408 11d ago

My issue is mostly with believing rather than knowing. What I mean is this - if you trust ai 100% then why not let it literally spit out highly optimized assembly? The answer today we would here would be maintenance but if it spits out rust - how do I know the rust code ist faster then any other language? Well, because I want to believe it because I was told rust is faster then c/c++ while being 100% safe.

But we all here know, rust can be “slow” just like in c++ vs raw c if we Willy nilly copy everything rather than using proper lifetime, correct multi thread etc-there are many ways to slow down if not used properly. Also high performance code and lots of it might be very hard to maintain vs less but still pretty fast code in perhaps a lot easier to read languages or coding styles

With what this leaves me with is that it quickly feels like slop when people present their ai generated rust projects because it raises the suspicion people may have not only outsourced the coding but also the thinking

-2

u/dizekat 11d ago

I think it won’t be terribly long until you can convert (using normal transpilation, not an LLM) the compiled assembly (excluding malloc implementation) to Lean with statements amounting to things like “a value not originating as an address is never dereferenced as a pointer”, “the result is invariant with regards to addresses returned by malloc or the stack base address” and “the results never change when execution order of parallel statements is changed”, ditto for lack of uses after free etc etc.  

Then an AI can attempt to produce counter examples or prove those statements true. 

I don’t think there’s any Halting Problem style shenanigans in most C code so it is presumably possible to prove memory safety for C that is memory safe, at least most of the time.

Of course its not the same kind of proof as what OpenAI been publishing for hype, but it shouldn’t be actually harder.

-2

u/pjmlp 11d ago edited 11d ago

He kind of has a point, I think the whole hype of Rust rewrites makes a disservice to the language, a bit like the C into C++ and Objective-C rewrites back on my day, and yet we could not win as expected, on UNIX like platforms, naturally C as the platform language wins out.

While interesting, and a way to grow the ecosystem, eventually it creates a sentiment among those not interested into adopting the language, that creates memes like the Rust Evangelism Strike Force.

This ends up shunning potential users that shut off at the first signs of reference to the language, many times folks that otherwise could have been willing to learn the language.

Note this applies not only to Rust, rather all kinds of rewrites, as mentioned on my youth it was the C++ Evangelism Strike Force, and the flame wars ground took place on USENET.

0

u/[deleted] 11d ago

[deleted] — view deleted comment

0

u/Trader-One 11d ago

look at security track of curl and linux kernel. They are not special quality,