Thursday, August 09, 2012 8:50 PM
Could you please give me an example to explain the strong-typing and weak-typing etc....
Thursday, August 09, 2012 9:02 PM
- Marked As Answer by ardmore Friday, August 10, 2012 12:39 PM
Thursday, August 09, 2012 9:35 PM
My take on it?
Strong-typing is compiler enforced declaration and maintenance of variable types such that you do not fall into the trap of performing operation and analysis on types which are incompatible with each other.
Weak-typing allows ambiguities and maintenance of variable operations is moreso on the coder, opening up possibilities of creating difficult to trap errors.
In most cases even strongly-typed languages contain aspects of weak-typing. However, strongly typed languages often force the coder to declare language constructs to engage the weakly typed system. The Object type in .NET is a prime example of weak typing. An Object can hold anything because all things are derived from Object, however, at this level, you can do close to nothing with it. To get it out of this state you must convert or cast the Object into a type which is compatible with the object stored in it to do anything of value with it. Casting operators are a part of the "language constructs" which you must use to essentially tell the compiler that you know what you are doing.
Of course, this is but one possible take on the question.