In my earlier post, I tried to state the most common accepted definitions for static, dynamic, strong, weak and safe typing. In that article I mentioned that the definitions are sometimes unclear, and there is a lot of confusion on the topic. Some further research led me to several resources which convinced me that the issue of typing is a big mishmash that lacks any coherent consensus. Take static typing, for instance. C++ is a language that is considered statically typed by almost anyone you ask. However, in addition to a static_cast operator, it also has a dynamic_cast, which is by definition a way to check types and cast between types in runtime. Pascal, another statically typed language, also has 'workarounds' for the type checking of the compiler. Strong typing is even more controversial. This is what Wikipidia says:
In computer science and computer programming, the term strong typing is used to describe how programming languages handle datatypes. The antonym is weak typing. However, these terms have been given such a wide variety of meanings over the short history of computing that it is often difficult to know what an individual writer means by using them.
It goes on to quote the programming language expert Benjamin C. Pierce (author of several books on the subject):
"I spent a few weeks... trying to sort out the terminology of "strongly typed," "statically typed," "safe," etc., and found it amazingly difficult.... The usage of these terms is so various as to render them almost useless."
An excellent exposition of the controversy was given by Mark-Jason Dominus, a renowned Perl guru and the author of "Higher order Perl". In a newsgroup thread, Mark wrote:
From a brief survey of web documents about strong typing, it appears that the description 'strongly typed language' does *not* have any useful or agreed-upon meaning. The confusion is not simply about where to draw a line on a linear scale of type granularity or degree of error checking or anything like that; it's not that some people think a strongly-typed language needs fifty types and others think it needs only thirty. There appears to be a fundamental confusion about the basic meaning of the term 'strongly typed language'. In a couple of hours, I found eight different and incompatible definitions of 'strongly typed language': 1. A language is strongly typed if type annotations are associated with variable names, rather than with values. If types are attached to values, it is weakly typed. 2. A language is strongly typed if it contains compile-time checks for type constraint violations. If checking is deferred to run time, it is weakly typed. 3. A language is strongly typed if it has compile or run-time checks for type constraint violations. If no checking is done, it is weakly typed. 4. A language is strongly typed if conversions between different types are forbidden. If such conversions are allowed, it is weakly typed. 5. A language is strongly typed if conversions between different types must be indicated explicitly. If implicit conversions are performed, it is weakly typed. 6. A language is strongly typed if there is no language-level way to disable or evade the type system. If there are casts or other type-evasive mechanisms, it is weakly typed. 7. A language is strongly typed if it has a complex, fine-grained type system with compound types. If it has only a few types, or only scalar types, it is weakly typed. 8. A language is strongly typed if the type of its data objects is fixed and does not vary over the lifetime of the object. If the type of a datum can change, the language is weakly typed. Some of these are contradictory; some are merely orthogonal. Many came from class notes for undergraduate CS courses. Not all of these instructors and experts can be mistaken. The only sensible conclusion is that there is no agreement about what it means to be a strongly typed language. Examples are no help here. I found several pages that asserted: ... that C is a strongly-typed language. ... that C is a weakly-typed language. ... that C++ is a strongly-typed language. ... that C++ is a weakly-typed language. ... that Lisp is a strongly-typed language. ... that Lisp is a weakly-typed language. ... that Perl is a strongly-typed language. ... that Perl is a weakly-typed language.
Read the full thread here and a follow up discussion on Reddit here.

Comments

comments powered by Disqus