I had a brainbench exam recently, got high mark, but there were a couple of questions which were hard for me. Maybe it's because english is not my native language... One of the questions is:
Which one of the following describes type-safety?
I think it's 1 or 5, but they sound weird to me anyway :(
What do you think?
In essence, type safe variables are key pillars of a safe and robust program. This is so because the algorithms that use these variables are rest assured that these variables will only take values from a well-defined domain. Thus, this ensures the integrity and quality of the data and the program.
TypeSafe means that variables are statically checked for appropriate assignment at compile time. For example, consder a string or an integer.
Type safety is sometimes alternatively considered to be a property of facilities of a computer language; that is, some facilities are type-safe and their usage will not result in type errors, while other facilities in the same language may be type-unsafe and a program using them may encounter type errors.
Typesafety is a tool for writing type-checked code in Python. In languages like C++, Java, etc., this is a language-level feature, but Python has no such feature. With the advent of annotations it is however possible to write code with type notations. Typesafety is a means to enforce that those notations are valid.
Type Safety is the feature of a language designed to make good on [Robin Milner][1]'s famous slogan about ML programming: well-typed programs cannot go wrong.
The slogan needs some unpacking before it can be properly understood, but it basically means that programs cannot fail because of a runtime type error, i.e. when the parameters applied to constructor or a function have values of incompatible type.
Consider a language that allows integers, integer functions as first class values, function abstraction and partial function application, and which defines the usual integer arithmetic operators as binary functions. The property of type safety is what the compiler enforces to ensure that both of the arguments to the addition operator are expressions that reduce to integers and not to functions. If a program is well-typed, then the compiler can emit an executable object for it. Otherwise, it flags the programming error and aborts.
Actually I think it's Choice 5 because type safety has nothing to do with Security.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With