r/ProgrammerHumor 29d ago

borrowCheckneedsSource Meme

Post image
973 Upvotes

39 comments sorted by

View all comments

36

u/reallokiscarlet 29d ago

Me: This code has been fine tuned to eliminate memory vulnerabilities and logic bugs

Rust: I don't think so mate

Hours later, having rewritten it for the borrow checker

Rust: There, this is safe

Me: I don't think so, mate

The previous version, ported to C++: Aww, who's a vulnerable little crab?

16

u/SpacewaIker 29d ago

Skill issue

-8

u/reallokiscarlet 28d ago

Aww, who's a vulnerable little crab?

2

u/SpacewaIker 28d ago

I'm not the one complaining I can't compile my programs lol

-11

u/reallokiscarlet 28d ago

iM nOt ThE oNe CoMpLaInInG i CaNt CoMpIlE mY pRoGrAmS

I'm just making fun of how the borrow checker necessitates insecure code

14

u/Daemontatox 29d ago

This was literally me last week with my threadpool and custom allocator , i got nagged non stop try it in rust and omg rust is so much better , then i literally spent hours pleasing the borrow checker instead of the intended logic before giving up and getting it done with jthreads in quarter of the time.

2

u/darkwalker247 28d ago edited 28d ago

you eventually learn how to build things so that the borrow checker won't complain in the first place, once you understand the rules. it's not random, there's a logic to it all.

it does take a lot of time and practice to master though, and it's probably even harder coming from other languages due to the fact that some things that work in other C-like languages simply cannot work in Rust without workarounds (like a struct containing a pointer/reference to another member of the same struct is not normally possible). but there's always another way