Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Programming languages and programs (as wells as individual functions, objects, etc.) are often described as being "safe" in one way or another. For example, they could be "type safe", "memory safe", "exception safe", "thread safe" - even "reentrant". Each of these concepts is about preventing erroneous or damaging code from executing, which makes them pretty important considerations in language and program design.

So if I wanted to be super-pedantic about safety, what are all the different kinds of safety I could consider? Or could there be any number of them, leaving me to hope that I know all the ones which could be important for me?

The context of the question involves comparing languages like Haskell to languages like C++: pure Haskell is great if you want to guarantee type, memory and thread safety. In C++, we can circumvent any of these. So I was thinking: "If we wanted to make a perfectly safe language, what are all the kinds of 'safety' that we could consider?"

share|improve this question

closed as not a real question by MichaelT, Robert Harvey, Martijn Pieters, Glenn Nelson, Dynamic Mar 9 '13 at 21:50

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
why are you asking? are you trying to solve some practical problem? –  gnat Aug 18 '12 at 19:53
    
@gnat: I'm mostly just musing at the moment. But the context of the question involves comparing languages like Haskell to languages like C++: pure Haskell is great if you want to guarantee type, memory and thread safety. In C++, we can circumvent any of these. So I was thinking: "If we wanted to make a perfectly safe language, what are all the kinds of 'safety' that we could consider?" –  Ken Wayne VanderLinde Aug 18 '12 at 20:15

1 Answer 1

Safety in all cases is about avoiding ambiguous state. If it's memory it's a question of "For a given unit of memory, what is stored there? How can one be sure?" Same with types. "For a given arbitrary piece of code, what rules does this code follow?"

The base idea is that you always want to be able to predict what output you will get, given a particular input.

share|improve this answer
    
Thanks for the answer. It definitely shows the relationship between the different kinds of safety that I listed. But if it's a matter of predictability, then would you say that program safety (when taken to the extreme) is the same as program correctness? –  Ken Wayne VanderLinde Aug 18 '12 at 19:41
1  
@KenWayneVanderLinde Safety does indeed make program correctness easier. One of the main selling points of strong typing systems is detection of bugs at compile-time. However, it's not the same. A program might still be wrong simply by solving the wrong problem. For instance sqrt(x) return x*x; will always be a bug, no matter what safety rules you apply. –  luiscubal Aug 18 '12 at 21:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.