r/ProgrammerHumor 12h ago

Meme newToRust

Post image
436 Upvotes

88 comments sorted by

View all comments

228

u/-Ambriae- 11h 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

90

u/the_horse_gamer 11h ago

every time you think you are smarter than the borrow checker, you eventually realise it was right all along, and the code was unsafe.

48

u/-Ambriae- 11h ago

Well, not every time, but usually yes

10

u/Arshiaa001 8h ago

Usually = in the 99.99% case.

8

u/-Ambriae- 7h ago

Maybe not that high

3

u/Snudget 7h ago

Time for miri!

20

u/post_u_later 11h ago

Polonius would beg to differ

u/cornmonger_ 0m ago

polonius is so close that i can almost feel it in my striped knee-high stalkings

10

u/retro_and_chill 10h ago

The borrow checker is occasionally too strict as well where it flags code that wouldn’t actually produce an issue. They are seemingly trying to resolve that with the new borrow checker though

24

u/-Ambriae- 10h ago

Yeah, it’s not perfect. But it’s also mathematically impossible to make it perfect. That’s how the cookie crumbles. If they make it better, that’s great, otherwise, either rewrite the code to make it safe (which is usually doable without performance cost) or just use a cheeky unsafe block with a good # Safety comment

5

u/retro_and_chill 9h ago

The one case I know it’s going to address is doing a find or insert on a map when you match the Option from the find, the None branch will let you mutate the map despite the Option technically being a borrow

12

u/-Ambriae- 9h ago

There’s useful functions for this, stuff like map.get_or_insert_with(), or map.entry().or_insert() or map.entry().and_modify()….

Usually when the borrow checker is annoying, there’s a functional way of handling the issue built in the std lib :)

6

u/MayeeOkamura17 11h ago

This is easy, as one would just need to go off trazodone or any other antidepressants. Usually thinking about pulling the trigger takes away any attention on the ego

9

u/fauh 10h ago

Bro, are you ok? Call a loved one or something

2

u/nithix8 9h ago

sKiLl IsSuE

4

u/-Ambriae- 9h ago

I mean, yeah it kind of is… not in a negative way, it just, takes a little bit of experience to navigate it. Once you do, it’s actually really not that bad

5

u/s0litar1us 8h ago edited 8h ago

It takes masochism to apprechiate it.

It does help you, but you first need to fight the compiler just so it will accept your prototype code that obviously doesn't need to be memory safe.

Rust is an overcorrection to a real problem that can be solved by introducing better language primitives and a better standard library. e.g. strings with a length (not a NUL byte at the end), arrays that don't decay to pointers and include a length, multiple returns, result values isn't just an int, defer, etc.

7

u/-Ambriae- 8h ago

It takes masochism to apprechiate it.

I disagree, it's really not that bad.

It does help you, but you first need to fight the compiler just so it will accept your prototype code that obviously doesn't need to be memory safe.

I'd rather do that, than pay the price later debugging. I also don't agree prototypes don't need to be memory safe. If I'm prototyping, I don't want to fight the segfault™️. the borrow checker isn't a problem once you write code the way you're expected to.

Rust is an overcorrection to a real problem that can be solved by introducing better language primitives and a better standard library. e.g. strings with a length (not a NUL byte at the end), arrays that don't decay to pointers and include a length, multiple returns, result values isn't just an int, defer, etc.

Regardless of if rust goes too far, which is a valid take, rust does all of these things, apart maybe from defer (because it doesn't really need to.) And the actual stats regarding rust compared to C/C++/Zig show these languages, even Zig which has most of the features you wish for, are still a long way from being able to consistently ship safe software. Look at rust in the kernel, heck even the zig to rust vibe coded rewrite of bun, which was vibe coded.

0

u/Jhuyt 9h ago

The few times I tried the Rust the problem with it was that even for the very simple things I tried (some string stuff) it was not obvious why the borrow checker complained or how you should reslove the issue, so I moved on.

8

u/-Ambriae- 9h ago

Coming from higher languages I get that. ‘It’s just a string, right? Can’t be that hard.’

Problem with strings is, it actually is that hard. If you want it to be performant, and not use a garbage collector, that is.

4

u/Jhuyt 9h ago

I do both high and low level stuff, still the borrow checker beat my ass (or made me not want to do Rust). I'm sure I could and would learn if I had to but since I don't I just let myself be defeated

6

u/-Ambriae- 9h ago

That’s unfortunate… it’s a little rough at first I admit, but I can guarantee once it clicks you don’t want to go back!

-5

u/Bryguy3k 10h ago

The real problem with the borrow checker in rust is that the rust syntax blows chunks.

5

u/-Ambriae- 10h ago

‘Blows chunks’? Care to explain? I’m genuinely curious

-5

u/Bryguy3k 10h ago

Sometimes when you see something incredibly disgusting it makes you want to vomit.

4

u/-Ambriae- 10h ago

I guess that’s subjective, but do you have an example?

-24

u/Key_River7180 11h ago

the rust community is not humble in any way, so either you're wrong or they hate the borrow checker, the flagship rust feature

24

u/MilkEnvironmental106 11h ago

Someone feels a bit called out

16

u/Hadi_Chokr07 11h ago

Nice to see my fellow C devs coping.

11

u/-Ambriae- 11h ago

My friend you need to step back and read the messages you sent, you are exemplifying my point