Hacker News new | ask | show | jobs
by mempko 25 days ago
Honest question for people. I'm a C++ dev and I'm seeing a lot of moves to rust. Everyone is using agents to move stuff to rust and I tried it myself. The amount of insane hardrive space usage (over 90GB of build artifacts that constantly need cleanup) is that normal? What am I doing wrong. Are people seeing advantages after a move to rust that wasn't there in C++ (assuming no new features). Like is your project better after moving to rust in obvious ways?
8 comments

I have the same problem and am regularly `cargo clean`ing hundreds of gigabytes of build artifacts. It is a real problem. I feel like I need minimum 4TB of SSD space just to comfortably work at the scale I'm working now in Rust. That's just for the working space of the target folders across worktrees.

I just think agents benefit a lot from having unavoidable feedback in the dev loop, and Rust affords that through its strictness. It's easier for agents to fall into the pit of success with Rust. I do think it's somewhat lacking in compile-time features, though.

Once I spent a month debugging a UAF bug, in a messy C++ codebase.

With rust, those class of errors are very difficult to arrive at, unless you specifically make it so.

with rust, the "risk" gets moved from runtime to compiletime. I'll take a 1TB build bloat over code crashing in prod. any day.

It's expected. Cargo has very conservative cache cleanup (once per month IIRC).

There's incremental compilation cache that generates lots of churn (although Rust's compilation unit is a crate, "queries" in the compiler are cached individually, creating many cache entries per function per type).

The other half of the disk space is debug info, because abstractions that optimize down to zero runtime code still carry all of their source-level debug info.

These can be adjusted in build profiles if you're ok with coarser debug info or less fine-grained caching.

Cargo has no cache cleanup for `target` on stable.
It's normal. But you can somewhat mitigate by:

- Making sure you compile with as few profiles as possible.

- Disabling debug info (or setting it to "line-table-only") for the default profile.

90gb? i've ran cargo clean on a single project and reclaimed over 700gb before.

but i still love rust ofc

Jesus, that makes the JavaScript ecosystem look moderate by comparison!
The difference is that this accumulates over time. You'll only get this if you haven't run "clean" for some time (likely months).
it was days, but it was related to something the agent was doing with tests and targets, where it was basically compiling a billion variations of the almost 500,000loc, 1100 deps, and 50+ crate project it had slopped together lol.
Shared libraries (i.e. not building every damn dependency) would fix this problem real quick in many situations, but of course, Rust people don't want to commit to an ABI in order to keep their options open. I don't think it makes sense much longer - at this point "can't do shared libraries" seems more like cultural inertia.

Two or so ABI breaks with a few years between them also seem quite survivable.

Isn't the advantage memory safety?

When I mentioned, after C++26 failed its vote, that maybe they should use this extra time to focus more on memory safety, I got downvoted instead.

Surely that attitude isn't helping their situation.

You probably read too much into the downvotes, and people who downvoted you in the other thread might not even be the same people deciding on the future of C++.

I didn't downvote you (that's not something I do) but I didn't find your comment particularly relevant or on topic. This disapproval thing and working on memory safety don't seem related at all. Someone told you they had the impression that you were pushing for Rust without mentioning it. Your comment might have felt like you were backseat driving as well. More memory safety in C++ would be cool, but do you have actual ideas on how to achieve this? There are a lot of reasons people could have downvoted you.

You shouldn't worry too much about it though, just relax and forget about it. It's fine. Happens to the best of us.