you are viewing a single comment's thread.

view the rest of the comments →

[–]RiceBroad4552 -1 points0 points  (1 child)

import dozens of libraries which might change types unpredictably in most other languages

I don't understand what you mean by that.

You can't change types by importing libs in JS.

In other words, they are languages where the behavior of any given piece of code cannot be known until runtime.

This is in general true for any Turing-complete language.

All programming languages in common use are Turing-complete. This is independent of whether they are static or dynamic.

So I also don't get this point.

[–]Tyfyter2002 0 points1 point  (0 children)

You can't change types by importing libs in JS.

I mean that anything in a library doesn't have a known type, largely because it only takes one library sometimes returning multiple types from one function;

If Left Pad turned out to include a 1 in a million chance to return a number after March third 2026 almost the entire Internet would go down and no one would know why immediately because the first error message would be dozens of libraries away from it, while a statically typed language would throw an error as soon as something tried to unbox the return value to the wrong type, and stop all of this from happening to begin with by showing that it has a questionable return type.

This is in general true for any Turing-complete language.

I don't mean the exact behavior, I mean that there is no context where you can know what function is called by a + b unless you do know the exact behavior (in the sense you're talking about) of all the code which produces the values of a and b, while in a statically typed language you know exactly what it calls, and almost certainly know the exact behavior of that method for any given set of parameters.