Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

More broadly:

> "No way to prevent $THIS" say users of only language where $THIS regularly happens

A weird psychological quirk I've noticed (of myself, and others) is we'll often exhibit a sort of 'programming language xenophobia', where we apathetically accept (or don't even notice) unpleasantries of our language of choice, yet be quite averse to the unpleasantries of other languages.

Maybe it's due to sunk cost; time/effort has already been spent finding work arounds for or adapting to the warts of our native tongue, whereas doing so for unfamiliar languages would require additional effort.



No way to prevent "this", says C++ programmer.


Just use Python it uses 'self'


In Python, you can easily just not type "self" (or whatever you named the 1st arg).

In C++, you can not not type "this", at least if you don't, "this" will be looked up anyway.


I would rather have unpleasantries that make the language safer vs unpleasantries that make it more vulnerable. Especially when the unpleasantries in question don’t even make the language easier to use.


C standard: "Undefined behavior means such a situation can't happen."

Me: "If it can't happen then it would be fine to just crash on those situations, right? Because such a crash would never be reached. Can we get that?"

C compilers: "No. Would you want to crash on signed integer overflow, for example?"

Me: "Yes? Would be safer than the current situation at least."

C compilers: "What, no, that would make your programs imperceptibly slower. Would you even like that?"

Me: "Yes, I'll be able to live with that."

C compilers: "Well, the answer is still no."


It would have taken you less time to look up -fwrapv / -ftrapv / -fsanitize=signed-integer-overflow + -fsanitize-undefined-trap-on-error than write out that misleading dialog. :)


Fair.

Last time I checked ubsan was a few years ago for a small program, and I've read stuff about it not being suitable for anything outside development (more like a valgrind complement than a release option) because of how it messed with environment variables and linked libraries or something, so I might not have the full picture.


C is more likely to define wrapping arithmetic. Wrapping is defined as undefined for compatibility with MIPS processors that support checked arithmetic.


There’s probably a large selection bias at work as well – people who care about those specific unpleasantries will avoid that language in the first place.


This is definitely a thing I recognise in myself, a year and a half of writing Scala daily has made me much more prejudiced against Java than I was before.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: