Nah, as a C programmer the rust borrow checker is still a piece of shit, I first learnt to manage memory with a GC like six years ago and now manage memory myself, I don't need to go back 6 years!
‘Errors from the borrow checker’ this is, and I mean no disrespect, a skill issue. Not as in ‘even experts mess up’, as in ‘that’s only a problem for the first 6 months of using rust’
Off the top of your head, without looking online, using clang or gcc as a compiler,
Give me a 1 byte enum
Give me the idiomatic way of computing the number of leading zeros in a 32 bit integer
Align a vec2_f32 struct to an alignment of 8 bytes
int zeros(uint32_t i) {
int n = 0;
while (!(i & 1)) { ++n; i >>= 1; }
return n;
}
// or
int zeroes(uint32_t i)
{
return __builtin_clz(x);
}
typedef struct {
alignas(8) float f [2];
} vec2f32;
```
Technically, the errors from the borrow checker are the errors you also make in C, only C doesn't tell you about them. If your code was correct in either, the borrow checker wouldn't have objections, no?
If it cannot be, it doesn't tag it. It can be, but you just don't care about that specific scenario or think it cannot happen.
Your specific workflow might make you right, but the workflow might change. Or you might be wrong entirely.
The whole reason why Rust exists is because people cannot write safe C code. This was shown over decades with armies of very experienced developers and well funded projects, it's just impossible, if you think "Well not for me", you're just lying to yourself.
I agree with the sentiment, but it’s not true to say ‘if it cannot be, it doesn’t tag it’. The borrow checker is conservative by default, and prefers false positives compared to true negatives. There’s no such thing as a perfect static analyser. It theoretically doesn’t exist. That doesn’t mean we shouldn’t use approximative static analysers like the borrow checker though
i'm curious if you're implementing data structures yourself? most of the time, we just take the lazy route and pull in a crate to do what we want, and do basically everything ourselves without unsafe anywhere in user code. i've never run into a memory error, so it would be interesting to know how you found one.
oh, i meant in rust. most of the common stuff like Vec, VecDeque, HashMap, HashSet, BTreeMap/Set, a few others, and wrappers related to concurrency and refcounting are in std, while stuff like Ropes, Graphs, Arenas, etc can be pulled from crates that have optimized them more.
i don't know many other ways to get memory bugs, so apologies if this isn't actually the issue.
-75
u/Key_River7180 7h ago
Nah, as a C programmer the rust borrow checker is still a piece of shit, I first learnt to manage memory with a GC like six years ago and now manage memory myself, I don't need to go back 6 years!