principleMinor
Untyped vs Unityped
Viewed 0 times
unitypeduntypedstackoverflow
Problem
-
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
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
Solution
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:
-
PLT people currently call JS "untyped" in the sense "not statically typed".
-
Because "most people do not want...", PLT definition of "type" should be changed to cover both static and dynamic types.
-
Languages which have 1 type should be called "unityped" instead.
-
JS has 7 types according to its specification, so it's neither "untyped" nor "unityped" (but it is "statically unityped").
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:
-
PLT people currently call JS "untyped" in the sense "not statically typed".
-
Because "most people do not want...", PLT definition of "type" should be changed to cover both static and dynamic types.
-
Languages which have 1 type should be called "unityped" instead.
-
JS has 7 types according to its specification, so it's neither "untyped" nor "unityped" (but it is "statically unityped").
Context
StackExchange Computer Science Q#63533, answer score: 4
Revisions (0)
No revisions yet.