Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This question is all about <a href="http://dictionary.reference.com/browse/semantics" rel="nofollow">Semantics</a></p> <p>If I give you this data: <code>12</code> what is it's type? You have no way of knowing for sure. Could be an integer - could be a float - could be a string. In that sense it's very much "untyped" data. </p> <p>If I give you an imaginary language which lets you use operators like "add", "subtract", and "concatenate" on this data and some other arbitrary piece of data the "type" is somewhat irrelevant (to my imaginary language) (example: perhaps <code>add(12, a)</code> yields <code>109</code> which is <code>12</code> plus the ascii value of <code>a</code>).</p> <p>Let's talk C for a second. C pretty much lets you do whatever you want with any arbitrary piece of data. If you're using a function that takes two <code>uint</code>s - you could cast and pass anything you want - and the values will simply be interpreted as <code>uint</code>s. In that sense C is "untyped" (if you treat it in such a way).</p> <p>However - and getting to Brendan's point - if I told you that "My age is <code>12</code>" - then <code>12</code> has a type - at least we know it's numeric. <strong>With context</strong> everything has a type - regardless of the language.</p> <p>This is why I said at the beginning - your question is one of semantics. What is the meaning of "untyped"? I think Brendan hit the nail on the head when he said "no static types" - because that's all it can possibly mean. Humans naturally classify things into types. We intuitively know that there is something fundamentally different between a car and a monkey - without ever being taught to make those distinctions. </p> <p>Getting back to my example in the beginning - a language that "doesn't care about types" (per-se) may let you "add" an "age" and a "name" without producing a syntax error... but that doesn't mean it's a logically sound operation.</p> <p>Javascript may let you do all sorts of crazy things without considering them "errors". That doesn't mean what you are doing is logically sound. Thats for the developer to work out. </p> <p>Is a system/language which doesn't enforce type safety at compile/build/interpretation time "untyped" or "dynamically typed"? </p> <p>Semantics.</p> <p><strong>EDIT</strong></p> <p>I wanted to add something here because some people seem to be getting caught up on "yeah, but Javascript does have some "types"". </p> <p>In my comment on someone else's answer I said: </p> <p>In Javascript I could have objects I've built up to be "Monkeys" and objects I've built up to be "Humans" and some functions could be designed to operate on only "Humans", others on only "Monkeys", and yet others on only "Things With Arms". Whether or not the language has ever been told there is such a category of objects as "things with arms" is as irrelevant to assembly ("untyped") as it is to Javascript ("dynamic"). It's all a matter of logical integrity - and the only error would be using something that didn't have arms with that method. </p> <p><strong>So, if you consider Javascript to have some "notion of types" internally - and, hence "dynamic types" - and think this is somehow "distinctly different from an untyped system" - you should see from the above example that any "notion of types" it has internally is really irrelevant.</strong> </p> <p>To perform the same operation with C#, for example, I'd NEED an interface called <code>ICreatureWithArms</code> or something similar. Not so in Javascript - not so in C or ASM. </p> <p>Clearly, whether or not Javascript has any understanding of "types" at all is irrelevant. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload