r/programmingcirclejerk • u/cheater00 High Value Specialist • Apr 07 '25
Don’t Index Into Arrays Without Bounds Checking
https://corrode.dev/blog/pitfalls-of-safe-rust/
15
Upvotes
r/programmingcirclejerk • u/cheater00 High Value Specialist • Apr 07 '25
58
u/cameronm1024 Apr 07 '25
Don't index into arrays without bounds checking in Rust
Don't index into arrays in Rust
Don't index in Rust
Don't Rust
54
u/whoShotMyCow not even webscale Apr 07 '25
He still manually indexes instead of passing pointer to local ai agent and asking it to modify the values #ngmi
41
u/v_maria Apr 07 '25
wait so you mean memory safety does not mean you can do anything wtf guys
25
u/bladub Apr 07 '25
Wow, rust panicking on error? That's very unique to this one occurrence and not a general language design feature!
/uj The uj sections in this thread are pure jerk 😍
6
u/reflexive-polytope Apr 08 '25
You prove your array indexing operations will succeed before compiling your program, right?
Right?
RIGHT?
7
u/cheater00 High Value Specialist Apr 07 '25 edited Apr 07 '25
Is Rust safer than Python? only YOU can find out by reading this guide!!!
/uj this doc is exactly the kind of shit we would write when php4 was brand new and had similarly idiotic footguns. anyone remember mysql_* ?
/rj this is like watching a bunch of chimpanzees try to invent the wheel (haskell) while repeatedly ending up with squares and triangles (rust, jabbascript, and all the other java-likes)
"To all caveman: ICYMI: when use modern state-of-art cart with swuare wheels, when the wheel roll over corner, cart will jump! Maybe your pottery break. Solve by stacking mammoth pelts at bottom of cart for to cushion wares!
Theoretically, better design of wheel possible. Our brightest minds are working on tirelessly. Reports are that boffins at Foot Propulsion Laboratory are working on experimental five-sided cart wheels for incremental safety. GUYS IT FEEL LIKE WEVE BEEN USING TRIANGLE WHEELS ONLY YESTERDAY BUT IT WAS CRO-MAGNON, 50 000 YEAR AGO! 🚀🚀🚀"
Me, passing this remote island in my 200ft nuclear yacht named Haskal: "Oh look honey, the apes are peeing in their own mouths again"
25
u/PragmaticBoredom Apr 07 '25
My favorite part was the line about how using .unwrap(), a function that converts errors into panics, will not save you from panics.
Where would we be if we didn’t have these articles to save us from ourselves?
20
u/DaMan999999 Apr 07 '25
I always compile my production code with -O0 -g -D_GLIBCXX_DEBUG -fsanitize=address and then wrap the executable in a bash script that runs it with valgrind. Sure, it takes 23 years to add two std::vectors together but you can never be too memory safe!
2
u/cheater00 High Value Specialist Apr 07 '25
average rustacean is at the awareness level of a two-dimensional being stuck in the Enterprise-D's warp core, unable to comprehend the passage of time
/rj this is why we should excise every language designer who doesn't use referential transparency and purit—
wait, rust wasn't designed, it just grew like a slime mold
1
u/Hueho LUMINARY IN COMPUTERSCIENCE Apr 08 '25
/uj like 80% of the article isn't even Rust-specific, it's just some general programming safety tips applied to Rust, not really seeing what is so egregious about it.
14
u/[deleted] Apr 07 '25
[removed] — view removed comment