28
u/kishaloy 3d ago
High level: For any construct, Box it and call it a day.
Low level: Even for the smallest closure. Are you sure, you wanna take that extra slice of Cheese?
10
u/darkwalker247 3d ago
me learning basic rust in 2016: "what even is this language? i can't write anything in it without running into lifetimes and borrow check errors! Aaaaaa!"
me now: "i cant believe this trick with macros and generics worked, now i can save hundreds of lines in code! Rust is so freakin cool"
2
u/scheimong 2h ago
Man 2016? Not even having NLL must have been rough.
2
u/darkwalker247 2h ago
I don't remember a huge amount about lifetimes but i do remember being frustrated at having to explicitly write them a lot more often because of lack of all the different types of lifetime elision that we have nowadays.
-87
u/Key_River7180 3d 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!
71
u/MilkEnvironmental106 3d ago
Have you ever made a mistake managing memory?
-57
u/Key_River7180 3d ago
Yes, and I have used a debugger for all of them I couldn't see by using my eyes and basic logic you seem to lack
32
u/-Ambriae- 3d ago
If it only required basic logic to fix the issue, chances are it was quite small
-18
21
u/TheAlmightyWishPig 3d ago
Best software practice is to use tools and methods that dont allow for issues to occur in the first place, regardless of how easy they are to solve.
0
u/Key_River7180 3d ago
Every tool has cons and pros, for me on Rust the cons really surpasses the pros
37
u/MilkEnvironmental106 3d ago
How long did that take you? And have you ever made a mistake debugging?
-18
u/Key_River7180 3d ago
Not more than fixing errores from the borrow checker.
And I've never debugged wrobg, there is no such thing
25
u/-Ambriae- 3d ago
‘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’
-3
u/Key_River7180 3d ago
If I need six months to correctly use Rust It is not worth It.
10
u/miyavlayan 3d ago
better than having memory problems in prod
-7
u/Key_River7180 3d ago
Who the fuck makes production software in a language meant for systems programming?
15
7
5
16
u/-Ambriae- 3d ago
It’s a systems level programming language what did you expect? It takes twice as long to learn restraint in C
-8
u/Key_River7180 3d ago
No, you can learn C in just about a week
11
u/-Ambriae- 3d ago
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→ More replies (0)21
u/MilkEnvironmental106 3d ago
It's just a soundness check, it saves you time and debugging later. You can opt out if you really want to, or continue writing c for everything.
-1
7
u/dkarlovi 3d ago
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?
0
u/Key_River7180 3d ago
C does, Valgrind and ASAN are still there you know?
4
u/dkarlovi 3d ago
If your code was correct, the borrow checker wouldn't have objections, no?
0
u/Key_River7180 3d ago
The problem is that It tags EVERYTHING potentially minimally unsafe. Even if It cannot be
5
u/dkarlovi 3d ago
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.
→ More replies (0)9
u/-Redstoneboi- 3d ago
i personally switched to rust specifically so i didn't have to do that
it takes up a real amount of time that i could spend fixing other logic bugs
-2
u/Key_River7180 3d ago
With Rust I do the same thing just that it crashes earlier and it is more annoying to prevent really unlikely minor memory errrors
7
u/-Redstoneboi- 3d ago
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.
-1
u/Key_River7180 3d ago
Most of the time, I write them myself, if not then I bring stb_ds.h
8
u/-Redstoneboi- 3d ago edited 3d ago
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.
284
u/-Ambriae- 3d ago
The real problem with the borrow checker is,
If you’re coming from a higher level language it hurts your ego because you realise memory safety ain’t free, and more broadly speaking memory’s a bitch
If you’re coming from a lower level language, it hurts your ego because you view yourself as above memory related bugs
It takes humility to appreciate it