Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

You'd think that a self-styled "programming junkie" wouldn't confuse strong and static typing, or weak and dynamic typing.


Making the "strong/weak" versus "static/dynamic" distinction is much more common in dynamic typing circles than static typing circles. And it makes total sense. Static typing people think of types as being syntactic. "Dynamic" typing seems like a misnomer--either the syntactic terms have strong types or they don't.


Common usage has definitely varied over the time I've used it. I remember one professor back in school even referring to C as strongly typed and Scheme as weakly typed.

I think some of the confusion is that the nature of the two sets of labels are commonly misunderstood. They're supposed to represent two orthogonal dichotomies about how languages design. In truth there is an orthogonal pair of dichotomies in there, but it's not captured by that set of labels. And the labels aren't really orthogonal.

The real dichotomies concern two different places where you can track type information: It can be associated with variables, or it can be associated with values. Some languages that represent the possibilities well are:

  - C: Variables, but not values
  - Ruby: Values, but not variables
  - C#: Both values and variables
  - FORTH: Neither variables nor values.
As for how they're commonly described: C is the classic example of static and weak, and C# is a good example of static and strong (though admittedly it has facilites for switching both off in a controlled manner). Ruby is dynamic and strong.

But nobody wants to call FORTH dynamic and weak, and for good reason: The very phrase "dynamically typed" implies that types are tracked, just dynamically. But FORTH doesn't track types at all; it's much more correct to describe it as untyped.

So that's where it breaks down: While strong vs. weak corresponds well to the question of whether types are associated with values, dynamic vs. static is not actually an orthogonal dichotomy, because the word dynamic describes a decision about both ways of tracking type: Dynamic languages associate type with values but not with variables. And my earlier description of Ruby as "dynamic and strong" is redundant.


I don't see the error he's making, would you mind pointing it out?


From Wikipedia:

- Static Typing: "A programming language is said to use static typing when type checking is performed during compile-time as opposed to run-time." [1]

- Dynamic Typing: "A programming language is said to be dynamically typed when the majority of its type checking is performed at run-time as opposed to at compile-time." [2]

- Strong Typing: "A type system is said to feature strong typing when it specifies one or more restrictions on how operations involving values of different data types can be intermixed. The opposite of strong typing is weak typing." [3]

- Weak Typing: "One claimed advantage of weak typing over strong typing is that it requires less effort on the part of the programmer because the compiler or interpreter implicitly performs certain kinds of conversions. However, one claimed disadvantage is that weakly typed programming systems catch fewer errors at compile time and some of these might still remain after testing has been completed." [4]

Links:

[1] https://en.wikipedia.org/wiki/Type_system#Static_typing

[2] https://en.wikipedia.org/wiki/Type_system#Dynamic_typing

[3] https://en.wikipedia.org/wiki/Strong_typing

[4] https://en.wikipedia.org/wiki/Weak_typing


Not sure why everyone's being so cryptic, so it's probably me that's the confused one. Let me try to guess:

"There is a wikiality driven split in the English language.

Camp A says that a strongly typed language prohibits immoral implicit conversions, such as "1" + 1 => 2 or even more grotesquely, "1000" == "1e3" => true.

Camp B says that a strongly typed language gives each value a type, and that all operations which do not have well-defined semantics will signal an error rather than allow operations to execute which assume incorrect typing.

Camp A currently owns the articles "weak typing" and most of the article "strong typing". Camp B is settling for teaching the controversy in "Strong vs Weak typing" and putting passive-aggressive little notes on all the articles that Camp A's view is mistaken. "

Did I get it right? If so, camp B is correct and camp A are being dicks about terminology that they're getting wrong.


Everything before 'Did I get it right?' is correct.

I have no opinion on the bit after that. :-)


We know what the definitions are; the confusion is that I don't see where exactly in the article he is confounding them. I'll read it again...


I agree. I'm not noticing a mistake unless he has since corrected it.


The OP's statements are about type declaration, which is not necessarily a feature of static typing but of strong typing.

It is possible for a language to not have these declaration and still be static (ie; compile-time type inference).


Although there is some degree in preference with programming languages, I find it much more common to see people using hammers on screws because that's the tool they KNOW.


That informed people may have preferences different than one's own does not preclude the possibility that some people's preferences are based on their being uninformed. But it is hubris (and not the virtuous kind) to presume that's any particular person's reason for disagreement, or that it's the most common.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: