Strong and weak typing
The terms "strong" and "weak" are extremely ambiguous. Here are some ways that the terms are used:
Sometimes, "strong" means "static". That's easy enough, but it's better to say "static" instead because most of us agree on its definition.
"a" - 1, which we might call "weak typing". But almost all languages provide some level of implicit conversion, allowing automatic integer-to-float conversion like
1 - 1.1. In practice, most people using "strong" in this way have drawn a line between "acceptable" and "unacceptable" conversions. There is no generally accepted line; they're all arbitrary and specific to the person's opinions.
Sometimes, "strong" means that there's no way to escape the language's type rules.
Sometimes, "strong" means memory-safe. C is a notable example of a memory-unsafe language. If
xsis an array of four numbers, C will happily allow code that does
xs, giving whatever value happens to be in the memory addresses after those used to store
Let's stop here in the name of brevity. Here's where some languages fall on these metrics. As shown, only Haskell is consistently "strong" by all of these definitions. Most languages are ambiguous.
|Language||Static?||Implicit Conversions?||Rules Enforced?||Memory-Safe?|
(An entry of "Depends" in the "Implicit Conversions" column means that the strong/weak distinction depends on which conversions we consider acceptable.)
Most uses of "strong" and "weak" on the web are vague and ill-defined value judgements: they're used to say that a language is "good" or "bad", with the judgement dressed up in technical jargon. As Chris Smith has written:
Strong typing: A type system that I like and feel comfortable with
Weak typing: A type system that worries me, or makes me feel uncomfortable