4 ms·
> If somebody stays away from typed languages, ... These people who stay away from typed languages, who are they and what are they using? Shell? Awk? Assemble
by kazinator 12y ago
> If somebody stays away from typed languages, ...
These people who stay away from typed languages, who are they and what are they using?
Shell? Awk? Assembler?
When is a language untyped: is it when you can misuse an operand by applying the wrong operation, with no diagnosis and strange, non-portable consequences? Or is when the character string "1.3" can be used as an arithmetic operand, automatically becoming a floating-point approximation of "1.3"? (If that is "untyped", how is it that "1.3" is identified as a character string, and how is the context identified as requiring an arithmetic operand?)
Or is it untyped when wrong type operands do something unpredictable, but dumb?
Bash:
$ string=abcd
echo $(( string + 3 ))
3
$ number=4
$ echo $(( number + 3 ))
7
That must be untyped. No?
- freyrs3 12y ago> When is a language untyped There's the formal definition of type and there's the colloquial definition of type. A type in the context of the article means a formal type, it is an syntactic classifier that is part of the static semantics of the language. The properties you describe ( string/number exceptions ) are part of the dynamics of the language, which is a separate concept. Dynamically typed languages quite often use boxed values with an attached runtime tags which are colloquially referred to as "types" even though they have nothing to do with static types. If you read the article in the context of "type" meaning "static type" it will make more sense.
- kazinator 12y agoDoes that mean I can search and replace every occurrence of "type" in the article with "static type"? Are you sure dynamic types have nothing to do with static types? What about compilers for dynamic languages which reason about type, like that if the program calls (symbol-name x), it is inferred that x must hold a string, so that a subsequent (cos x) is inconsistent? Is such a compiler is reasoning about something which has nothing to do with static type?
- kd0amg 12y agoAre you sure dynamic types have nothing to do with static types? "Static type" does not really mean "class of values." That is a common use of static types, but they can also be used for things like tracking what resources are available/released or describing what exceptions a function might raise.
- chongli 12y agoIf the compiler is applying reasoning before the program is run then it is by definition performing static type checking.
- kazinator 12y agoBut what it's reasoning about coincides with the dynamic type which will exist at run time, so that means we cannot say the two have nothing to do with each other. It's the same knowledge, just known at different times, right? Just because we have stuffed some knowledge into tags that exist at run time (and chosen suitable machine representations to make that possible) doesn't mean it's a different class of knowledge.
- chongli 12y agoTypes are propositions for which the text of your program is the proof. Type theory arose as an alternative to set theory in order to deal with Russell's paradox[0]. Types have been around for a lot longer than computers have. They have nothing at all to do with a running program. [0] https://en.wikipedia.org/wiki/Russell%27s_paradox https://en.wikipedia.org/wiki/Russell%27s_paradox
- kazinator 12y agoWhat is missing from the above articulation of a view is that the run-time state of the program is also text. (It's made up of the symbols "0" and "1", at one level.) There can be propositions about that text.