6
  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.

Thanks.

Tim
  • 5,035
  • 5
  • 37
  • 71

2 Answers2

4

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").

Alexey Romanov
  • 3,217
  • 19
  • 23
0

REXX has two types, strings and commands. The command interpret interprets a string.

An untyped language is like untyped lambda calculus. It only has lambda abstractions, no strings, no numbers, truly only the one type that apparently does not really count because it is a function.