This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Strongly typed, weakly understood
Feed Title: David Buck - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/buck-rss.xml
Feed Description: Smalltalk can do that
I keep hearing different definitions of the term "Strongly Typed" from different places. I'm now starting to wonder if there's an "official" definition in any sense of the word "official" and what that might be.
My own interpretation of "strongly typed" lines up roughly with the one in HyperDictionary:
Strict enforcement of type rules with no exceptions. All types are known at compile time, i.e. are statically bound. With variables that can store values of more than one type, incorrect type usage can be detected at run time.
From this definition, Smalltalk can be considered strongly typed. All variables are implicitly defined as a reference to an object. There's no need for manifest typing i.e., explicit type declarations for each declaration. All variables can store values of more than one type and incorrect type usage can be detected at run time (normally by a 'message not understood' exception).
I find it distressing, then, when I hear "strongly typed" being used instead of "staticly typed" or "manifest typed".
One particularly quirky definition comes from Whatis.com. It states:
A strongly-typed programming language is one in which each type of data (such as integer, character, hexadecimal, packed decimal, and so forth) is predefined as part of the programming language and all constants or variables defined for a given program must be described with one of the data types. Certain operations may be allowable only with certain data types. The language compiler enforces the data typing and use compliance. An advantage of strong data typing is that it imposes a rigorous set of rules on a programmer and thus guarantees a certain consistency of results. A disadvantage is that it prevents the programmer from inventing a data type not anticipated by the developers of the programming language and it limits how "creative" one can be in using a given data type.
Another bizarre usage is seen in articles like this where they state:
"So what, exactly, is a strongly-typed .NET collection", you ask? It's an alternative to System.Collections.ArrayList, which deals only in typeless "objects". ArrayList works great, but its typical usage requires quite a bit of casting to appease the compiler. Such wanton downcasting is a very error-prone coding style... the use of a strongly-typed collection class eliminates the need for casting, thus allowing the compiler to catch many common coding errors at compile-time, rather than run-time.
They seem to be saying that code that does casting is not strongly typed. As I see it, so long as a type error is detected at runtime when an invalid cast is made, the language is still strongly typed. In fact, in this quote, they are attributing the term "strong typing" to the specific coding technique rather than the language.
Frustrating? Yes. I know that terms tend to get confused. This is one, though, that is very widely confused. It makes the term virtually useless.