For most of my career, I've been working with strong static typed languaged such as Java. For this reason, probably I've mixed up these two typing dimension (strongness and staticness). I came upon this link, which says that they are actually orthogonal dimension. I read it, but still can't understand this distinction. 'weak static' sounds oxymoron to me, because static sounds like they will check stuff at compile time, while weak is the opposite.
The page uses Pascal and C as examples of weak static, and CommonLisp and Python as examples of strong dynamic, but unfortunately I don't know enough of these language to help.
What does weak static typing/strong dynamic typing mean? How can a language like C and Python be like Java in one aspect, but like Perl in others?
Best Answer
The terms strongly typed and weakly typed dont have a agreed-upon definition. Therefore, unless you define what you mean by "strongly typed" and "weakly typed", it is impossible to answer your question.
It makes a "great" argument in a flamewar, because whenever someone is proven wrong, they can just redefine the terms to mean whatever they want them to mean. Other than that, the terms serve no real purpose.
It is best to just not use the terms, or, if you use them, rigorously define them first. If you see someone else use them, ask them to define the terms.
This is what Benjamin C. Pierce, author of Types and Programming Languages and Advanced Types and Programming Languages has to say:
Luca Cardelli, in his Typeful Programming article, defines it as the absence of unchecked run-time type errors. Tony Hoare calls that exact same property "security". Other papers call it "type safety" or simply "safety".
Mark-Jason Dominus wrote a classic rant about this a couple of years ago on the comp.lang.perl.moderated newsgroup, in a discussion about whether or not Perl was strongly typed. In this rant he states that within just a few hours of research, he was able to find 8 different, sometimes contradictory definitions, mostly from respected sources like college textbooks or peer-reviewed papers. In particular, those texts contained examples that were meant to help the students distinguish between strongly and weakly typed languages, and according to those examples, C is strongly typed, C is weakly typed, C++ is strongly typed, C++ is weakly typed, Lisp is strongly typed, Lisp is weakly typed, Perl is strongly typed, Perl is weakly typed. (Does that clear up any confusion?)
Everybody has their own definition. Some that I have seen are:
In Type Theory, there exists the notion of one type system being stronger than another. In particular, if there exists an expression
e1
such that it is accepted by a type systemT1
, but rejected by a type systemT2
, thenT2
is said to be stronger thanT1
. There are two important things to note here:The only definition that I have seen consistently applied is: