Tuesday, October 13, 2009, 09:57 PM - .Net
Posted by Administrator
What is strong-typing versus weak-typing? Which is preferred? Why?Posted by Administrator
Strong type is checking the types of variables as soon as possible, usually at compile time. While weak typing is delaying checking the types of the system as late as possible, usually to run-time. Which is preferred depends on what you want. For scripts & quick stuff you’ll usually want weak typing, because you want to write as much less code as possible. In big programs, strong typing can reduce errors at compile time.
Weak typing is where a language allows you to treat blocks of memory defined as one type as another (casting). Languages like C and C++, although statically typed, are weakly typed.
Languages like Perl and PHP are weakly typed because you can do things like adding numbers to strings and the language will do an implicit coercion for you.
Languages like Java, C# and Python are strongly typed - there is no way you can add a number to a string without doing an explicit conversion.




( 3.1 / 368 )

Calendar



