Click to See Complete Forum and Search --> : Strong typing vs. weak typing?


matthias_k
September 13th, 2004, 06:16 AM
Hey there,

what exactly does it mean (technically) when a language does "strong typing"? And what would weak typing be in contrast?

KevinHall
September 14th, 2004, 12:19 PM
"strong typing" and "weak typing" is sort of a fuzzy area. I personally think there is rarely a perfectly strong or perfectly weak system. It's usually more like "stronger typing" and "weaker typing"

Stonger typing leans more towards the programmer specifiying what types he needs and intends to use and the language helps enforce these rules. C++ is an excellent example of a "strong typed" language. But it isn't perfectly strong, for it allows the conversions of types: ints to doubles for example. Although it is likely to be one of the most strongly typed languages out there.

Weak typing leans more towards the programmer not specifying the types necessary and this tends to lead to (a) something that is easier to write (b) code that is more generic but (c) more susceptible to runtime errors. Scripting languages are generally pretty weakly typed. VBScript and JavaScript are great examples -- they don't even require types at all.

matthias_k
September 14th, 2004, 02:29 PM
I see. So Ada must definitely be a language with very strong typing I guess :)
[I'm preparing a seminar paper about Ada, that's why I asked. Ada has very broad support of defining own types and has harsh rules about type casting].

Thanks Kevin.