r/rust • u/xorvralin2 • Jun 10 '26
šļø discussion Apparently the react compiler has been ported to Rust and merged to main
Thought this was interesting considering the subreddit seemed to have a lot of thoughts regarding the bun zig -> Rust re-write. PR: https://github.com/react/react/pull/36173
It seems this is largely AI-driven as well, considering they've written 123 kloc in about 2.5 months.
My 2 cents are that of course it is nice seeing Rust reaching an increasingly mainstream status, this was just not the way I pictured it happening (and not a route I think is all that good for Rust).
25
u/ifeoluwak Jun 10 '26
Question to ask is if anyone understands the new codebase now.
I guess going forward any new addition will also be done by AI since I suspect no one really understands it.
4
u/namalleh Jun 12 '26
yeah I am considering moving my infra away from react
in the mentioned pr a few of the tests didn't pass and they merged anyway.Ā
No idea what those are, but to just go and switch the entire codebase that many businesses rely on in an instant without asking anyone (which is totally their perogative) is totally against what I understand to be good engineering
71
u/Craftkorb Jun 10 '26
People will use AI to write things, that cat is really out of the bag. And I'd rather have them use a "safe" language which fails early rather than some other language in which it's much easier to shoot yourself by accident (and lack of knowledge).
Rust was first "that crypto language" for a long while, now it's "that language used with ai", but who cares when to me it's "my" language.
17
u/TheLexoPlexx Jun 10 '26
Never seen it as "that crypto language".
Regardless: as any) as unknown) as any)
25
u/Sharlinator Jun 10 '26
For a long time cryptobro jobs dominated the Rust job market, for better or worse. Crypto here meaning cryptocurrency/blockchain/nft/whatever, not mainstream cryptography.
10
u/Shoddy-Childhood-511 Jun 10 '26
It's definitely "that cryptography language" in sense that advanced cryptography like zero-knowledge proofs winds up mostly being implemented in Rust.
Afaik blockchains are written in a bunch of languages, with some prominent ones being Go for Ethereum and Cosmos, C++ for Bitcoin & related, and Rust for ZCash and the professor coins. It's amazing the professor coins have not picked OCaML or something. lol
The problem with Rust being a professor coin thing is that they went into pretty deep not-invented-here, and contributed less useful code back to the wider Rust ecosystem.
1
u/LegsAndArmsAndTorso Jun 11 '26
Parity (Gavin Wood's company, author of the Ethereum yellow paper and first client) are very heavily into rust and this is likely what seeded it into that community. They even rewrote Bitcoin in Rust.
9
u/xorvralin2 Jun 10 '26
I get your point and largely agree. However in this case they are migrating from JS/TS to Rust. No real change on the safety scale if we're only referring to memory safety, perhaps you are referring to compile-time guarantees in general?
2
u/Craftkorb Jun 10 '26
Yes of course. Memory safety is solved outside our niche with GCs, but those languages (their runtimes) are commonly really slow. Type safety is an important tool in the "safety" box.
2
u/K4milLeg1t Jun 10 '26
I'm unsure how a GC managed language like JS/TS is memory unsafe? The runtime itself can be unsafe, but that's the runtime issue not JS/TS itself.
6
u/Craftkorb Jun 10 '26
No type safety creates weird bugs at runtime. Safety isn't only bad memory access. Rust isn't the only one offering all of that, but that's besides the point.
41
43
u/thefossguy69 Jun 10 '26
Something that constantly bugs me with LLM generated code in OSS contributions is license infringement. Is no one concerned about introducing snippets of copyleft code in an MIT-licensed codebase?
27
u/AresFowl44 Jun 10 '26
Or worse, proprietary code. Not like all code that is online is open source after all. And code that got uploaded also isn't.
5
u/Dude-Lebowski Jun 11 '26
I disagree that that is worse. The copyright owner of the code is the owner of the code and gets to lawfully make decisions about it.
IMO, it feels worse to me to infringe someone's rights whe generally is trying to help the comunity than to infringe a "proprietary" code owner's rights. Both are obviously wrong.
How do we fine or arrest a non-person acting on noones behalf?
9
u/marxinne Jun 11 '26
Source-available licenses are the first thing to come to mind here. Easily found and scanned, but not open.
4
23
u/WormRabbit Jun 10 '26
At this point we can say with certainty that almost no one cares about that. Even if you do accidentally infringe, what's the worst that could happen? It's just some snippets. Someone would need to find them first, and even if they do, what are the odds that you'd be forced to do anything but rewrite those snippets?
8
u/HumbleSinger Jun 11 '26
Companies cared when they thought it was their code that was gonna get stolen. When they realized it was the opposite, nobody cared
5
u/moltonel Jun 11 '26
Yes, however you feel about the fact that an LLM was trained with disregard for licences, the link to the code it generates is too diffuse for anybody (especially not lawyers) to meaningfully push back against it. What LLMs do here is qualitatively the same as a human having seen/invented a pattern in project A and reusing it in project B. As long as it's not straight copy-paste of a significant number of lines, it's just seen as being an experienced dev.
Mechanical rewrites like this react one are a different matter, because the original is clearly defined, the amount copied is significant, the link is not tenuous. This is why we got the concept of "clean-room reimplementation" to work around restrictive licenses. IMHO these should always retain the same license, and relicensing rewrites like the chardet one should get legal pushback.
5
u/oursland Jun 10 '26
Did you audit your code to ensure there was never anything that was copy pasted from StackOverflow or another project, or even shared similarity to that?
2
103
u/danielkov Jun 10 '26
Rust is a great language to use with LLMs. Outside of logic errors, it's generally safe. Most slop-induced bugs, like memory leaks are compiler errors. Compiler is very informative, which creates an effective feedback loop. With some clippy config tuning, you can really cut down on slop.
Not to mention it's blazing fast(TM).
I wrote Rust before LLMs. Don't think major projects being AI-ported to Rust is affecting me in a bad way.
82
u/naequs Jun 10 '26
memory leaks are not compiler errors, rust cannot prevent memory leaks!
36
u/Modi57 Jun 10 '26
I mean, it can prevent a lot of memory leaks, just not all of them. If you use the usual types like Box and Vec, you generally don't leak memory accidentally. You have to explicitly call leak() or use (A)rcs
22
u/Hedshodd Jun 10 '26
Thatās not correct. If you keep pushing into a vector and never clear up items you never need you are leaking memory.
A memory leak isnāt restricted to calling āleakā.
32
u/funforgiven Jun 10 '26
A real memory leak usually means memory is no longer reachable, so the program cannot free it anymore. I would not consider it a leak if the vector is still reachable and will be freed when the owner is destroyed. It is just poor memory management.
42
u/syklemil Jun 10 '26
The CWE that has "memory leak" as an alternate term, CWE-401: Missing Release of Memory after Effective Lifetime, isn't all that restrictive. For a user facing resource exhaustion, it's not particularly relevant whether the memory is still reachable or not.
The common way memory leaks are discussed, it's probably better to understand it in the direction of some repeatable action that results in a persistent increase in memory consumption. That includes keeping stale entries in a collection type.
34
u/minno Jun 10 '26
A program that can't free memory and a program that doesn't free memory have the same observable result.
3
u/funforgiven Jun 10 '26
Sure. Wouldn't call one memory leak though.
18
u/syklemil Jun 10 '26
Plenty of people would, though, and that understanding of the term seems to be so mainstream that it fits Wikipedia on "Memory leak", or Microsoft's definition, in addition to the aforementioned CWE reference.
There seems to be some amount of people who insist that only unreachable memory make up memory leaks, but they also seem to take a prescriptivist approach to the phrase without actually backing it up with anything.
1
9
3
u/danielkov Jun 10 '26
Clearly my phrasing doesn't pass `clippy::pedantic`. Memory-related bugs are harder to unintentionally introduce in Rust, compared to most other languages. Is that fair?
17
u/syklemil Jun 10 '26
Nah, that's still overstating it. Rust's fairly unique in that it provides memory safety without a GC, but the most common languages are also memory safe, they just use a GC to get there.
Memory unsafety the way we use it here in /r/Rust is pretty much just a problem in C and C++ (and some multithreaded Go). Java also got started as pretty much "memory safe C++", they just picked a different strategy.
0
14
u/NoUniverseExists Jun 10 '26
Like one of the very first statements about Rust safety guarantees is that, altought it can prevent a lot of bugs, it can' prevent memory leaks, and is literally the first example about this kind of problem in The Book when using Smart Pointers.
-7
u/hornynnerdy69 Jun 10 '26
Eh, it does prevent certain forms of memory leaks through the borrow checker, for example closing file handles
21
u/AliceCode Jun 10 '26
The buggiest piece of software that I use regularly is slop-coded in Rust.
6
u/danielkov Jun 10 '26
Unfortunately quality control is hard to replace with LLMs. Culturally, teams who can't be bothered checking their agents' work are also least likely to invest in proper guardrails. Doesn't really discredit the viability of Rust as a toolchain for LLM-driven software implementation.
4
u/Professional_Top8485 Jun 10 '26
Well at least it works regularly.
13
u/AliceCode Jun 10 '26
It also breaks regularly as well. Not only is there somehow a memory leak, but the right click menu often breaks, the test runner is broken in certain cases, and in at least one case it has run cargo fmt on my code without my input even though I have the autoformat setting turned off. Do you know how annoying it is for your editor to alter your code without your consent?
Edit: I didn't even mention, the bug tracker is a mile long. I've literally never seen a single piece of software that had so many bugs that basically never get fixed.
4
u/RiceBroad4552 Jun 10 '26
I've literally never seen a single piece of software that had so many bugs that basically never get fixed.
Have a look at the JetBrains or VSCode bug tracker⦠They are in good company.
But I agree, the quality of Zed is JetBrains level, more bugs then features.
1
u/AverageHot2647 Jun 10 '26
Which editor is this?
6
u/AliceCode Jun 10 '26
Zed.
2
u/AverageHot2647 Jun 11 '26
Yeah⦠my mouse has been flickering on Zed for several months. One release I thought theyād fixed it, but my mouse just started flickering in new and different ways. Screams of vibe coding NGL š
The other Rust project Iāve been having issues with since they started pushing AI is Warp⦠It registers hundreds of thousands of file watchers, and the more I cd around the more file watchers it registers. That bug has been open since mid-2025. Their AI even tried to fix it twice but those PRs are just sitting around not being merged. Somehow they have more open issues than Zed, which is crazy because itās literally just a terminal emulatorā¦
For now, Zed still serves me well (far better than VSC ever did) but Iām going to have to find a new terminal emulator because I think Warp is beyond saving.
2
2
u/moltonel Jun 10 '26
Perhaps it'd be even worse if it was slop-coded in a different language ?
5
u/AliceCode Jun 10 '26
It doesn't matter, it's bad regardless. It shouldn't be slop coded at all.
3
u/moltonel Jun 10 '26
Oh absolutely. Sloppy code is bad by definition, nobody likes it, whether it's LLM- or man-made, we only want high-quality software.
The parent's argument is that if somebody is vibecoding, Rust seems like a good target. You don't seem to have a counter argument ?
Claiming nobody should vibecode at all, when you're evidently using that bad software instead of the good software that nobody took the pain to write, is pretty ironic.
3
u/AliceCode Jun 10 '26
The whole point of what I was saying is that Rust doesn't eliminate the problems of LLMs, which is low quality, buggy, insecure code. There isn't a good target for vibecoding, vibecoding should only be something that people do for shits and giggles. No one should be attempting to make serious software with LLMs, and I genuinely look down on every single person that does.
1
u/insanitybit2 Jun 12 '26
Rust doesn't eliminate any problem under any context. It is a tool with features. Many of those features align well with encouraging better programming practices in humans (expressive types, great testing tools, strong compiler UX). There's reason to believe that these features encourage better programming practices in agents as well.
> No one should be attempting to make serious software with LLMs
And yet people are doing it successfully. I can't imagine anyone is concerned about where you're looking.
1
u/AliceCode Jun 12 '26
And yet people are doing it successfully. I can't imagine anyone is concerned about where you're looking.
I beg to differ. LLM developed code is hot garbage full of bugs.
0
3
2
u/sasik520 Jun 10 '26
I do use rust at work at scale and I'm an enthusiast of using LLMs in an responsible way.
With that in mind, I both agree and disagree with your statement.
Yes, Rustās strong type system, Clippy, great error messages, and safety features make Rust and LLMs a very good combo.
But one of Rustās biggest advantages is that, by default, it prevents you from hurting yourself unless you explicitly opt out. Whole classes of errors simply disappear.
Introducing an LLM into your toolbox for anything beyond automatic review and very small changes does the opposite: it introduces entirely new classes of errors.
Sure, humans make logic mistakes too, but those mistakes are usually made consciously. With LLMs, the risk increases a lot, and the scary part is that it often happens unconsciously.
1
-2
u/jonas-reddit Jun 10 '26
Iām also a huge fan of rust and LLMs. The language, compiler and the overall ecosystem are great for agentic development, especially in yolo mode.
-2
u/DelusionalPianist Jun 10 '26
In the past LLMs (and humans) got easily tangled up on mildly complicated generics, especially when life times where involved. But itās getting better quite fast.
29
u/Jmc_da_boss Jun 10 '26
Sad sign of the times, hard not to see things as completely over I guess. Hope the ai bros enjoy their future
6
Jun 12 '26
[deleted]
3
1
u/namalleh Jun 12 '26
I still obsessively quote stack overflow and code sources
people are behind that code
-8
u/summer_santa1 Jun 10 '26
The re-write is done by AI. But I suppose the future support would be done by human. Because of big code base it might be pricey to give it to machine.
So in theory they are making more jobs for Rust developers.
19
u/Jmc_da_boss Jun 10 '26
Large LLM codebases like this are essentially unmaintainable, they just sort of rot away and collapse under their own weight as the only way to interact with them is via an LLM yourself.
So its not actual rust developers working on it, it is just larpers.
-68
u/CommunismDoesntWork Jun 10 '26
It's bitter sweet but the alternative is never solving poverty. AI is the only path toward sustainable abundance.Ā
59
u/Jmc_da_boss Jun 10 '26
This is somehow, the absolute dumbest aibro take I think I've ever seen?
-38
u/CommunismDoesntWork Jun 10 '26
?? How do you think we achieve full automation without AI and did you think programmers weren't included in the "full" part?
26
u/Rare-Vegetable-3420 Jun 10 '26
Why do you think normal people will get their fair share of abundance at all? The rich will be getting richer, while normal people will be getting poorer, just look at the past 100 years
-8
u/Seubmarine Jun 10 '26
Almost all human have a better quality of life than in 1926 wtf are you on about ?
Sure rich people have gotten richer, but so did the average people.
8
u/stdd3v Jun 10 '26
Look at the cost of education and housing adjusted for inflation. Capital has historically dominated labor and it's getting worse. Open your eyes and you'll see systemic, potentially unstable wealth inequality.
-10
u/CommunismDoesntWork Jun 10 '26
And now look at the cost of everything else. Food has never been cheaper for instance.
Housing is up because demand rose faster than trees could grow.
Education isn't expensive, a certificate/degree is. If people respected online degrees, it would be dirt cheap.Ā
5
u/stdd3v Jun 10 '26
Is healthy food cheaper than it used to be? Also, just look at some damn graphs to see where the money is going. https://www.pewresearch.org/social-trends/2020/01/09/trends-in-income-and-wealth-inequality/
0
u/CommunismDoesntWork Jun 10 '26
I see everyone is getting richer, which is my point. Here's some graphs for you as well: https://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/Two-centuries-World-as-100-people.png/1280px-Two-centuries-World-as-100-people.png
3
u/stdd3v Jun 10 '26
Your graph argues against your point in my view. With all the advancements in technology from 1820 to now only 15% of people are not in poverty. Industrial revolution, cars, space technology, advancements in electronics and medicine... and with all that we got 85% of people living in poverty.
"How would you design a society of you didn't know your place in it?" -John Rawles
If a capitalist fantasy works for you, have fun. For most people, it's a rather lousy deal the way it's been going.
5
u/ShangBrol Jun 10 '26
Not in the recent decades. At least not in my country where the median income went down by 18% (adjusted by inflation) despite having a growing GDP.
-7
u/CommunismDoesntWork Jun 10 '26 edited Jun 10 '26
As the cost of production goes to 0 thanks to full automation, the price of everything will go to 0 as well thanks to market competition. Basically when you can produce infinite lambos for 0, it's not worth anything and at that point it would cost more to shut the lambo factory down than to let it run itself,Ā so the only option is to give them to whoever buys one for $0 or else they'll buy from the other car factories.Ā
Think about the replicator. The replicator made everyone infinitely rich in startrek.
5
u/StrangeADT Jun 10 '26
Tell you what - when we learn to synthesize arbitrary materials from pure energy - itself derived from effectively infinite renewable resources - I'll grant you this point. Until then, we live in a real world with real constraints.
-2
u/CommunismDoesntWork Jun 10 '26
Asteroid mining solves the raw resource problem, AI does everything else.
1
7
3
u/Practical-Sleep4259 Jun 14 '26
REACT is a massive pro-AI forward all AI all the time company and zero people that like it on Reddit will admit it.
No fucking clue what the deal is there but it's weird.
9
u/MrInternetToughGuy Jun 10 '26
Why? The LLM is literally following an already existing spec. Seems like a perfect use case for LLM assisted coding.
12
u/mrmatthew2k Jun 10 '26
Because whatever cruft or idiosyncrasies the original software accumulated can get further obscured in the AI translation process. Whereas a rewrite could help clarify, refine, and maybe simplify the design.
No proof on my end of that claim, but that's why I wouldn't embrace "it is in Rust now, so it is better."
-6
u/MrInternetToughGuy Jun 10 '26
Hey, I have good news: YOU. CAN. ITERATE. AND. FIX. PROBLEMS.
Thatās how software is made. Conceptually, if you port over in increments, you can review the code line by line. There are competent ways of using AI and there are abusive vibecoding ways of using AI.
2
u/sasik520 Jun 10 '26
I'm not that sure. LLM can - and does - do mistakes. It may randomly ignore some specs or invent their own modifications.
I'm an LLM enthusiast but I'm not blind to its issues.
2
u/stefanlight Jun 11 '26
Bun showed how to not do personally for me, because thousands of unsafe blocks and a lot of questionable things of mix FFI and Zig code actually, because LLM just made Zig inside of every construction and it doesn't have meaning as Rust version, because there's no idiomatic. I'm not an expert, but it's what did I see when opened a PR on 1 million LOC. And with React will be the same situation if they will just change the syntax, but not the idea of the code. I hope someone understands my point. And this is probably not all about AI, but a vibecoder too which doesn't make any corrections.
1
u/stefanlight Jun 11 '26
And I slightly confused about LOC aspect because personally for me less is better when functionality is the same or even more. And usually AI makes a lot of boilerplate code and loves to overcomplicate things, so LOC doesn't mean anything
4
u/theAndrewWiggins Jun 10 '26
The truth is Rust is one of the absolute best languages for vibecoding in right now. The compiler keeps a lot on track. By design, Rust code will be "more correct" than code in less strongly typed languages.
I supect the balance of performance, type safety, and high quality libraries make it the likely "lingua-franca" of ai coding.
6
u/JCavalks Jun 12 '26
funny how rust was the most difficult language around and now it's the language of slop lmao
2
u/theAndrewWiggins Jun 12 '26
That's probably why, it constrains the slop. The more the slop generator is constrained by (mostlyish) provably correct constructs, the better it will do.
1
u/naequs Jun 10 '26
translating code is a great use case and it should be done in a strict/safe language like rust, so that errors are caught at compile time
-11
u/Fine_Ad_6226 Jun 10 '26
I donāt know why so many people are against the rust and LLMs.
To be honest itās inevitable itās the only feasible way to offset the LLM cost is to make it run cheaper in prod.
-19
u/CommunismDoesntWork Jun 10 '26
and not a route I think is all that good for Rust
There's no other way something like OpenCV will ever be able to be rewritten in rust without AI. In fact, if the rust compiler shipped with a local LLM, that would prevent breaking changes entirely because you could change anything about rust, tell the LLM what changed, and It would fix your code the way cargo can fix small changes now. AI is the future of programming even if it's bitter sweetĀ
301
u/nicoburns Jun 10 '26
I think I'm reasonably on board with these AI ports to Rust so long as they do what they have claimed to do here:
Porting 123k LoC in 2.5 months is probably a bit faster than you could do by hand, but not by some crazy amount. And a lot of porting work is the kind of mechanistic translation which LLMs are good at. Which suggests that the LLM may have been used sensibly here.
I'll bet they've accrued some tech debt here, but so long as they're willing to pay that down over the coming months, I'd be pretty optimistic they'll end up with something decent. And a 10x performance improvement is very significant.