In computer science, weak typing (a.k.a. loose typing) is a property attributed to the type systems of some programming languages. It is the opposite of strong typing, and consequently the term weak typing has a number of different meanings, just as "strong typing" does.
One of the more common definitions states that weakly typed programming languages are those that support either implicit type conversion (nearly all languages support at least one implicit type conversion), ad-hoc polymorphism (also known as overloading) or both. These less restrictive usage rules can give the impression that strict adherence to typing rules is less important than in strongly typed languages and hence that the type system is "weaker". However, such languages usually have restrictions on what programmers can do with values of a given type; thus it is possible for a weakly typed language to be type safe. Moreover, weakly typed languages may be statically typed, in which case overloading is resolved statically and type conversion operations are inserted by the compiler, or dynamically typed, in which case everything is resolved at run time.
One claimed advantage of weak typing over strong typing is that it requires less effort on the part of the programmer because the compiler or interpreter implicitly performs certain kinds of conversions. However, one claimed disadvantage is that weakly typed programming systems catch fewer errors at compile time and some of these might still remain after testing has been completed. Sometimes implicit conversion occurs which will surprise unwary programmers and lead to unexpected bugs. For example, in PHP, the strings "1000" and "1e3" compare equal because they are implicitly cast to floating point numbers, even though they have distinct values as strings.
Famous quotes containing the word weak:
“A country is strong which consists of wealthy families, every member of whom is interested in defending a common treasure; it is weak when composed of scattered individuals, to whom it matters little whether they obey seven or one, a Russian or a Corsican, so long as each keeps his own plot of land, blind in their wretched egotism, to the fact that the day is coming when this too will be torn from them.”
—HonorĂ© De Balzac (17991850)