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

No, I'm pretty sure I understand the nature of Undefined Behaviour well.

It's not nonsense, since writing this I have watched several videos in which people playing with newer languages say [of Rust] "Oh, I guess I got that wrong, I'll fix it" when Rust's compiler tells them what they wrote is nonsense, but they do not make similar corrections in the languages where what they wrote is UB because it's never brought to their attention.

It's human nature, I assume what I wrote is correct, the machine accepts it, I guess it was correct. Right? Nope, for several of these languages - including C and the various "C successor" languages like Zig or Odin - the compiler blithely accepts nonsense and it has UB - that's my point here.

You lump together Java and C at the end which is silly. Java doesn't have UB except narrowly via clearly labelled "it's unsafe to use this" features. On the other hand in C even adding 200 and 300 together may be Undefined Behaviour in some contexts and you need a compiler vendor chosen flag if you even want to be alerted to the most obvious examples of this because the language doesn't care that you're about to shoot yourself in the foot.



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

Search: