1. From https://en.wikipedia.org/wiki/Programming_language#Type_system

    Typed versus untyped languages

    A language is typed if the specification of every operation defines types of data to which the operation is applicable, with the implication that it is not applicable to other types.[47] For example, the data represented by "this text between the quotes" is a string, and in many programming languages dividing a number by a string has no meaning and will be rejected by the compilers. The invalid operation may be detected when the program is compiled ("static" type checking) and will be rejected by the compiler with a compilation error message, or it may be detected when the program is run ("dynamic" type checking), resulting in a run-time exception. Many languages allow a function called an exception handler to be written to handle this exception and, for example, always return "-1" as the result.

    A special case of typed languages are the single-type languages. These are often scripting or markup languages, such as REXX or SGML, and have only one data type—most commonly character strings which are used for both symbolic and numeric data.

    In contrast, an untyped language, such as most assembly languages, allows any operation to be performed on any data, which are generally considered to be sequences of bits of various lengths.[47] High-level languages which are untyped include BCPL, Tcl, and some varieties of Forth.

    In practice, while few languages are considered typed from the point of view of type theory (verifying or rejecting all operations), most modern languages offer a degree of typing.[47] Many production languages provide means to bypass or subvert the type system, trading type-safety for finer control over the program's execution (see casting).

    As far as I can understand the above quote, is the differences between unityped and untyped languages that

    • for an untyped language, there is no concept of type, and any operation can apply to any value,
    • for an unityped language, all the values belong to exactly one type, and an operation can apply to either all the values or none of the values?
  2. If my understanding is correct, how can we understand the following quote which suggests to drop untyped in favor of unityped:

    From https://stackoverflow.com/questions/964910/is-javascript-an-untyped-language#comment49716735_9159863

    it would be nice if the PLT community dropped "untyped" in favor of "unityped". The definition of "untyped" meaning "just bits" actually makes sense. To use "untyped" to describe a language whose formal specification uses the word "type" and says that it has seven types (Undefined, Null, Number, String, Boolean, Symbol, and Object) is really confusing. Most people do not want to distinguish this notion of type from the PLT def.



You can understand this comment as not making much sense: he is proposing calling Javascript unityped precisely because its specification says it has seven types. He also says "I was glad to see that this answer referenced Harper's blog post" but that post is about why "type" should be used in PLT sense (static types only): i.e. why the two senses have to be distinguished and JS specification uses the term "incorrectly" (not in the way PLT does).

EDIT: on further thought, he doesn't actually say JS should be called "unityped". That is, maybe he proposes converting PLT to the definitions in Wikipedia:

  1. PLT people currently call JS "untyped" in the sense "not statically typed".

  2. Because "most people do not want...", PLT definition of "type" should be changed to cover both static and dynamic types.

  3. Languages which have 1 type should be called "unityped" instead.

  4. JS has 7 types according to its specification, so it's neither "untyped" nor "unityped" (but it is "statically unityped").

  • $\begingroup$ Thanks. Does a unityped type system mean the type system has exactly one type? Is the comment wrong? Note that he is a cs professor at a university and write textbooks on programming languages. $\endgroup$
    – Tim
    Sep 16 '16 at 14:48
  • $\begingroup$ Yes. Note that I wouldn't object to calling Javascript "statically unityped": just to this motivation. $\endgroup$ Sep 16 '16 at 14:52
  • 2
    $\begingroup$ What does statically unityped mean? How is it different from unityped? $\endgroup$
    – Tim
    Sep 16 '16 at 15:48
  • 1
    $\begingroup$ A good explanation of "unityped" (originally coined by Dana Scott I think) is by Bob Harper existentialtype.wordpress.com/2011/03/19/… Terminology "debates" can get crazy because different people can use the term "type" differently, so a single language can both have seven types and have only one type, depending on what you call a type. Harper's rationale for calling dynamically typed languages unityped is carefully laid out in the paragraph beginning "What does this have to do..." $\endgroup$
    – Ray Toal
    Sep 16 '16 at 20:38
  • 2
    $\begingroup$ Sorry, I didn't mean to endorse anything; I was pointing out that in day-to-day use people are happy to talk about JavaScript's Undefined, Null, String, Boolean, Number, Symbol, and Object as "types" while at the same time people in a PL context use "type" in the sense of Harper and say the language is unityped from that perspective. I suppose it's not wholly inconsistent if you keep the worlds separate. Lots of words have different meanings in different contexts, which is all I think is going on here. At any rate, McKenna's answer in StackOverflow is quite good. $\endgroup$
    – Ray Toal
    Sep 16 '16 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.