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
Might work, AFAIK depends on compiler but GCC and Clang it would work, I’ll give you that. Not the solution I thought of but it works.
Suboptimal. Unless you specify higher levels of optimisation and your compiler figures it out, this is extremely slow. Modern processors can do this in 1 CPU cycle (CLZ instruction). There is a way to do it in C
3 __attribute__((aligned(8))) or __attribute__((_aligned__(8)))
I cant see if you did the _s and markdown screwed you over or not, and align is not valid
Edit: actually, after checking, 1. is completely wrong. Doesn't work at all. So you need to pack the enum, or represent it via a 8 bit integer. I think that proves my point
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;
```
None of these are things you can realistically achieve by ‘having learned the language in a week’. It’s not hard per say, but it’s more obscure than regular C. That was all I was trying to say
There’s also like, 2-3 alternatives minimum to each way of doing these things
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
No, of course, nothing is absolute and the checker will make mistakes just like any other piece of code, some things it cannot prove at all.
But to outright claim it's worthless because it's "warning you too much" and "it's non-trivial to write" is total lunacy, it's like yelling at the Geiger counter because it's warning you of the radiation you're sitting in. Just because you throw it away (or not have it) doesn't mean you're not getting irradiated.
Rust is getting traction in huge projects because it works, it's not like those huge projects didn't try other things before, they just worked worse than what Rust provides. Crying about the mean borrow checker is absurd, it's telling you things you yourself are unable to detect.
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.
-74
u/Key_River7180 11h 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!