r/ProgrammerHumor • • Oct 24 '26

Meme dreamLanguage

Post image
1.4k Upvotes

210 comments sorted by

View all comments

Show parent comment

8

u/UdPropheticCatgirl Oct 24 '26

No language with undefined behavior can be safe… That’s entire problem with having it.

8

u/M4rshmall0wMan Oct 24 '26

“Avoiding null types is easy, you just gotta add a check every function.”

That’s such a non-human answer to a problem that shouldn’t even exist. You miss one, and your program blows up. That’s not a skill issue.

5

u/chat-lu Oct 24 '26 edited Oct 24 '26

The analogy I like to use is that it's like walking in a minefield with a detector. You just point it, press the button, and if it beeps there is a mine. Easy peasy.

How confident are you that you won't ever forget one time while crossing the whole field?

3

u/M4rshmall0wMan Oct 24 '26

Perfect metaphor. 

2

u/Batman_AoD Oct 24 '26

Hm, not sure I completely agree. Rust has undefined behavior in unsafe constructs, so perhaps "no language without guardrails around its undefined behavior" might be more accurate. But unfortunately it's necessary for languages with direct hardware/memory access to have some amount of undefined behavior. (It's also frequently stated that UB is necessary for modern optimizations, but I find that claim less believable, even having watched Chandler Carruth's talk defending that claim.) 

2

u/-Ambriae- Oct 24 '26

But that’s the thing, rust code that can have UB is opt in (supposing safe rust is void of UB which is not strictly speaking true, but is being worked on) whereas C++ UB isn’t even opt out

1

u/Batman_AoD Oct 24 '26

Right; that's why I proposed the "guard rails" phrasing. 

2

u/-Ambriae- Oct 24 '26

Fair. I think I didn’t understand your phrasing, sorry!

1

u/Batman_AoD Oct 24 '26

No worries!