4 ms·
Ask HN: What is the difference between a program that is “correct” vs. “safe”?
The two terms seem thrown around a lot in similar contexts, and I'd like to know what you all think.
- Tomte 11y agoIf I write a program that's supposed to kill somebody and it does, it is correct, but certainly not safe.
- cnvogel 11y agoCorrect: works exactly as intended (specified) Safe: Correct and does not have unintended and undesirable side effects. So, in my opinion being correct is a prerequisite for being safe.
- drdeca 11y agoedit: I am not even more confident that cnvogel is correct instead of me. Check their comment, not this one. I thought "safe" just meant it wouldn't ever crash or read or write to memory it shouldn't, and things like that, whereas correct means it meets some set of requirements exactly, and, because of this would probably also be safe. Which, is kind of backwards from what cnvogel said, and I don't have any reason for expecting myself to be more correct, so, I would suggest that you treat their comment to be more likely to be correct than mine. But if they are wrong this is what I think the difference is.
- drdeca 11y ago... I meant "now" not "not".
- brudgers 11y agoMy take: Correctness is a static mathematical property of the source code. Safety is a mechanical property of a program executing on hardware. Correctness is absolute. Either it is a proof [or possible proof] or not. Safety is relative. For a web application, it may mean handling javascript injection attempts. For a spacecraft it may mean handling random bit flips caused by cosmic radiation. Caveat: I'm not dogmatic about any of this. I'm not trying to handle all corner cases. And fundamentally, I believe words mean what we mean when we use them; that meaning isn't fixed by external sources. I'm just answering the question to a degree somewhat commensurate with the effort put into asking it.