News for hackers. Stuff that matters.
Re:Untyped Programs Don’t Exist by int_19h on Thursday December 06, 2018 @10:35PM (#18624941)
Values in JS still have different types (as evidenced by their different behavior). Variables could all be argued to have one type in JS, which is the root type (which everything else subtypes).

So no, JS is still not untyped, merely dynamically typed. An example of a language that also has only one data type for value would be something like Tcl, where the only type is a string - and everything else is just an optimized way to store certain kinds of strings, that could be removed without affecting semantics of any program.

Re:Untyped Programs Don’t Exist by kazinator on Friday December 07, 2018 @04:41AM (#18626277)
They could be argued, but that would be wrong. If we define a variable, give it the value 42 and then never change it over the lifetime of the image, then that variable's type is integer. Or, even more specifically, its type is the set { 42 }.

It may be the case that no such thing is actually analyzed and the implementation always retains the potential to reassign that variable; that doesn't change the mathematical fact that the set of values which that variable is fixed.

That the implementation is not interested in examining the type of a variable (let alone checking for consistency with the rest of the program) shouldn't be mistaken for the absence of type. There is a mathematical fact about the program that isn't constrained by the quality and depth of its implementation.

Re:Untyped Programs Don’t Exist by anon_d on Friday December 07, 2018 @04:45AM (#18626288)
Javascript is Unityped. In Haskell/ML, you would define the type of Javascript objects by doing something like this:

    data JSObj
      = Num Double
      | Str String
      | Obj (Hashtable String JSObj)
      | True
      | False
      | Nil
      | Undefined
Re:Untyped Programs Don’t Exist by naasking on Friday December 07, 2018 @11:16AM (#18628871)
> Values in JS still have different types (as evidenced by their different behavior).

Behaviour is based on values, not types. 1+2 will print out a different value than 1+1, but these expressions have the same type (typically).

> So no, JS is still not untyped, merely dynamically typed.

I said JS was unityped, not untyped.

Re:Untyped Programs Don’t Exist by int_19h on Friday December 07, 2018 @04:55PM (#18632052)
Values also have types, it's not something that's exclusive to expressions and bindings.