6 ms·
'break your code in surprising ways' is super vague. Saying 'may cause out of bounds memory access/writes should the input not be valid UTF-8' explicitly is pro
by Anderkent 9y ago
'break your code in surprising ways' is super vague. Saying 'may cause out of bounds memory access/writes should the input not be valid UTF-8' explicitly is probably more scary.
- steveklabnik 9y agoThe nature of undefined behavior is in fact super vague; it's not actually possible to say what will happen.
- infogulch 9y agoWhile technically true, a specific example helps the reader conceptualize what level of danger that means, when they don't already have a concrete understanding like you do. Recall that the breadth of experience for rust's userbase is much larger than e.g. C.
- steveklabnik 9y agoOh yeah, I mean, I'm not saying I disagree with adding detail, I can just see the impulse to not, since anything you say may or may not be true.
- infogulch 9y agome talking about rust's userbase steveklabnik's profile: "Rust core team" I'm guessing you know that a lot better than I do lol.
- steveklabnik 9y agoIt's all good! You're absolutely right, and it's easy to forget when you're inside a bubble.
- TickleSteve 9y ago> breadth of experience for rust's userbase is much larger than e.g. C Really? I think you mean the opposite here.
- steveklabnik 9y agoI read this as saying "not depth", that is, C programmers will have a deep understanding here, but since Rust is drawing in a lot of new blood, they on average will not.
- bonzini 9y agoJust say the worst thing that can happen, out of bounds access probably qualifies. :-)
- lfowles 9y ago"Could potentially emit code to rm -rf /"
- firethief 9y agoThat's the kind of vagueness that should sound like a warning to anyone considering that approach.
- kbenson 9y agoThe nature of warnings means that any time you make assumptions about those that might need the warnings having enough knowledge to correctly assess an ambiguity, you've likely just failed a portion of the people the warning was meant to help. The correct response when warning people of potential problems is never "oh, they should be able to figure out whether this applies to their case".
- Animats 9y agoRight. The correct answer here is to convert external data into UTF-8 once and keep it that way. You're probably not going to become compute-bound, even if you're just reading in text and writing it out again. The UTF-8 check is linear time.
- burntsushi 9y agoMost of the Rust programs I write are compute bound, and finding ways to avoid the separate UTF-8 validation step are critical to their performance.
- Animats 9y agoThat's because you write string search programs. Do those even need to run in UTF-8 space, as opposed to pure byte strings?
- gpderetta 9y agoIf you are reading text and writing it out you generally do not want to convert to utf8 as it is potentially lossy. Think of unix filters.
- Asooka 9y ago