4 ms·
If the bounds check fails at compile time then the program doesn't compile. This seems like it should be a reasonable ask for any programming language, but, app
by tialaramex 5y ago
If the bounds check fails at compile time then the program doesn't compile. This seems like it should be a reasonable ask for any programming language, but, apparently not.
And it probably applies to all general purpose languages but of course it doesn't apply to all the safe languages that aren't general purpose. You can't have bounds misses in WUFFS. When you try to touch array[x] in WUFFS, the compiler constrains the type of x to have a boundary limit according to the size of the array, reasoning that you can't very well have meant for it to be possible to overstep the bounds of the array at runtime. Trivial arithmetic mistakes you might find in unit testing or worse production with other languages are often compile time errors in WUFFS as a result.
- pjmlp 5y agoExcept bounds checking fail at runtime like 90% of the time.
- tialaramex 5y agoWell, like I said, in WUFFS this literally can't happen, WUFFS doesn't have any concept of runtime bounds checking, likewise it has no runtime overflow/underflow checking, if the compiler can't see why what you're doing will obey the constraints you don't have a valid WUFFS program at all (well, library, WUFFS is a special-purpose language so you're not going to go around writing whole programs in WUFFS) And it's still a pretty sad indictment when a compiler is looking at your access, can see it's outside the boundaries and doesn't reject the program because the language (e.g. C) wasn't defined with this obvious expectation. For me it's in the same category as the (now fixed in an errata) behaviour where as I understand it C++ 20 std::format didn't consider it a compile time error if you wrote format("check X: {} Y: {} and Z: {}", x, z) ... even though that's obviously an error, and it's obvious you can detect it at compile time, the original specification said nah, this code just blows up at runtime, good luck with that.
- pjmlp 5y agoHow would you write random app X? That is my point, I don't care about special niche cases.
- tialaramex 5y agoI think a lot of people would already consider the cases you've declared to be relevant - where dying due to bounds failure is unacceptable - to be niche cases which need to do their own work to stabilise and not act like this is everybody else's problem. It isn't, for example, as if explicitly checking bounds isn't possible in Rust if you want to do something other than give up. For example I would consider it acceptable if feeding badly corrupted MP3s to the MP3-capable CD-radio makes it stop working... until I disconnect the power and restart it. Nobody dies, if it's very annoying I should remove the offending MP3 file. Whereas if it causes random mayhem that's a problem because now troubleshooting is impractical and most likely the apparent solution is to replace the entire device. And remember that such "turn it off and on again" is considered acceptable even in some systems you probably deem safety critical, so long as it needn't happen when actively dangerous. For some years trains in the UK with a beacon-based safety system couldn't handle waking up next to a beacon, their firmware wanted to start by not seeing a beacon, then encounter beacons while travelling - so waking up next to one was confusing and they'd go into an error state. The fix? Mostly "don't park the train there when it's to be switched off", but when it happened inadvertently, they would move the train a few metres with its safety systems disabled, turn the power off, wait a few seconds, turn the power back on and no longer able to see a beacon it was now happy.
- pjmlp 5y agoThat is where I disagree, when you buy a pair of shoes that are somehow uncomfortable to wear, do you live with the pain or go to the shop to exchange them? Exactly that is what we are missing in the software industry, the niche cases of high integrity computing should be a common practice, just like most people usually don't put up with broken stuff when given the option. We need more liability not less.
- 5y ago