
Ask HN: What is the difference between a program that is “correct” vs. “safe”? - hellofunk
The two terms seem thrown around a lot in similar contexts, and I&#x27;d like to know what you all think.
======
brudgers
My 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.

------
cnvogel
Correct: 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
edit: 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
... I meant "now" not "not".

------
Tomte
If I write a program that's supposed to kill somebody and it does, it is
correct, but certainly not safe.

