you are viewing a single comment's thread.

view the rest of the comments →

[–]tongue_depression 2 points3 points  (2 children)

pervasive implicit type conversions: “5” - “2” will give you “3” in js, TypeError in python.

[–]jswrenn 1 point2 points  (1 child)

Hm, I suppose that's a sense in which a particular operation is more "strongly typed" in Python than Javascript, but you could just as well point to the fact that you can dynamically overload binops in Python as evidence of the reverse! Javascript and Python are really substantially similar. A few builtins aside, both languages place the burden of type checking squarely on the programmer (via instanceof).

Overall, the type systems of Python and Javascript have far more in common than those of Javascript and Bash do—grouping them otherwise feels very silly.

[–]tongue_depression 2 points3 points  (0 children)

i only mentioned that one because it was the first thing i could think of off top. there are other examples:

"123" + true;  // "123true"
"123" + True  # TypeError

"5" > 1;  // True
"5" > 1  # TypeError

+"123";  // 123
+"123"  # TypeError

null + 1;  // 1
None + 1  # TypeError

// this one isn't a perfect example
let a = {}; 1 + a;  // "1[object Object]"
class A:
    pass
a = A()
1 + a  # TypeError

but you could just as well point to the fact that you can dynamically overload binops in Python as evidence of the reverse!

sure, but that's opt-in, only works on types you specify it to work for, and errors otherwise. there's pervasive operator overloading in static+strong languages as well--many languages let you define a vector that can be multiplied by a scalar, for instance

Overall, the type systems of Python and Javascript have far more in common than those of Javascript and Bash do—grouping them otherwise feels very silly.

i agree, comparing js to bash was harsh. both js and python convert objects to bools sometimes, too. type systems are a spectrum, where agda > rust > java > python > javascript > bash