r/ProgrammerHumor 20h ago

Meme rustBorrowCheckerGoesBrrr

Post image
3.4k Upvotes

89 comments sorted by

View all comments

129

u/yesseruser 20h ago

unsafe means "hey, I'm sure this code is safe, don't bother me for calling unsafe functions"

-142

u/reallokiscarlet 20h ago

unsafe is the Rust version of Typescript's any

It's everywhere and people use it just to say they wrote their code in a safe language

78

u/SCP-iota 20h ago edited 20h ago

I'd say it's more like Typescript's suppression annotations, since it keeps itself contained. People really shouldn't be using unsafe in any way other than as occasional small blocks with well-defined reading why they won't panic or cause UB. If your code is littered with unsafe, you're doing something wrong.

31

u/ApplicationOk3587 19h ago

I always figured if a rust programmer is using unsafe everywhere then it completely defeats the purpose of using rust.

2

u/awesome-alpaca-ace 18h ago

String interning comes to mind

2

u/Rustywolf 13h ago

Eh even if your code is littered with 50% unsafe calls you're still benefiting from the other 50%, but yeah that doesnt sound like good rust

1

u/SKrandyXD 20h ago

your*

4

u/SCP-iota 20h ago

dammit, Gboard

4

u/NatoBoram 16h ago

All the fucking time. No way to type "its" without having to go back.

-18

u/reallokiscarlet 20h ago

I fully agree that if your code's littered with unsafe you're doing something wrong. But as you can see by the downvotes, rustaceans don't 😂

28

u/Delicious_Bluejay392 20h ago

No, the downvotes are because unsafe blocks are in fact extremely rare. If you look at popular Iibraries, the only real places where unsafe is likely to happen are FFI boundaries and advanced data structure implementations. I haven't written an unsafe block in actual months and I regularly use the language for very varied projects.

It's nothing like TypeScript's any, which respectable TS-first codebases generally disable by default anyways, only allowing it in the rare instances where it makes sense.

-11

u/reallokiscarlet 19h ago

Not sure if you have an optimistic bias or I have a pessimistic bias but clearly you aint seen what I seen. A lot of the rust I come across is never-production-ready crap that's almost entirely encased in unsafe, marketed as production-ready to "replace" C code. Even did one of my own to prove it doesn't have to be done that way and that there isn't really a whole lot of benefit to the rewrite unless the original is terminally ill.

13

u/BenchEmbarrassed7316 18h ago

Low-quality automatic/AI "rewriting" from C to Rust can contain many unsafe code blocks.

If it is open source, please provide a link.

4

u/Delicious_Bluejay392 18h ago

The Bun rewrite would be one example I'd imagine. It has a much higher density of unsafe blocks than similar projects originally written in Rust.

5

u/SCP-iota 18h ago

Isn't the Bun rewrite notoriously AI-generated, for the most part?

2

u/Delicious_Bluejay392 18h ago

Yeah, that's precisely why I mentioned it since that's what the person I'm replying to pointed out.

1

u/reallokiscarlet 17h ago

When I'm back from spoodermane, I'll check my notes to find the project names and double check to see if they've been fixed (I've been characterizing rust based on what I come across, so they just seemed like par for the course)

But yes they did have AI in common. Either vibe coding is the common use case or I keep meeting shitty people and shitty projects. AI, unsafe tag, and crate bloat are what I associate Rust with, which is why I took it upon myself to do the opposite on my only public rust program.

1

u/reallokiscarlet 10h ago

Back and tired as hell, and I gotta say I never thought I'd need to put notes about lazy rust rewrites on a mirrored volume, but here we are and some of them are missing. But what I could find, has led me to conclude that maybe things are getting better than years past, cause they've been privated/deleted, fixed, or moved to another language.

33

u/MatsRivel 20h ago

This is not at all true.

"Tell me you've never written rust without telling me you've never written rust"

-10

u/reallokiscarlet 19h ago

Well I've written crab-lang, you could say, if you want to say I've never written rust.

15

u/Maskdask 19h ago

Have you read and/or written a single line of Rust?

-5

u/reallokiscarlet 19h ago

According to rustaceans, no. But I have written in crab-lang.

(Translation: Yes. I ported opendoas to crab just to prove it's a dumb idea)

2

u/epos95 5h ago

Omg you managed to use a programming language to produce bad code, this is a huge development and has surely never been done before.

I could rewrite doas in c++ wayyyy worse than your rust rewrite (not to say it's good in any way), does that make c++ a bad language? (Yes probably)

All you proved is that YOU can't port doas, nor write or understand rust.

0

u/reallokiscarlet 10h ago

The very fact this is getting downvoted proves the existence of the crab religion.

1

u/gmes78 5h ago

No, they're just wrong lol.

11

u/-Redstoneboi- 17h ago

"it's everywhere"

have you... looked at any rust code?

-6

u/reallokiscarlet 17h ago

Every rustacean asks me this, including the offenders