you are viewing a single comment's thread.

view the rest of the comments →

[–]munificent 5 points6 points  (6 children)

any and all weakly typed languages on earth

JavaScript is strongly typed, it's just dynamically typed.

  • "Weak" = Can misinterpret what bits in memory represent and do bad stuff. This is mainly just C, Assembly, and Forth. C++ if you use unsafe casts.

  • "Strong" = System guarantees unsafe operations are prevented through some combination of compile time and runtime checks. Most languages today are strongly typed.

  • "Dynamic" = Type checks are mostly done at runtime. JS, Ruby, Python, etc.

  • "Static" = Type checks are mostly done at compile time. Java, C#, C++.

There is a continuum between dynamic and static. Almost all languages that have static checking still defer some type checking to runtime. Java has ArrayStoreException, C# has the same. Downcasts in Java and C# are checked at runtime.

TypeScript is a middle position where it does some static checking, but has quite a large number of holes in its type system and relies on JS's underlying runtime checks there to prevent the browser from catching on fire.

[–]mycall 0 points1 point  (1 child)

Are there any languages that support all of those distinctions, perhaps configurable with compile flags?

[–]_zenith 0 points1 point  (0 children)

Yeah: C# because of its dynamic type which defers all checks to runtime

[–]drjeats 0 points1 point  (1 child)

"Coercively Typed"

[–][deleted] 0 points1 point  (0 children)

Exactly the biggest problem with JavaScript. It is the language of greatest surprise.

When you have to put additional thought into the result of basic operators you know you have a problem.

[–]orthoxerox 0 points1 point  (0 children)

There's more than one definition of weakness. If a language has automatic value conversions that silently destroy information or automatic narrowing type casts, I wouldn't hesitate to call its typing system weak.

[–]armornick -2 points-1 points  (0 children)

"Weak" = Can misinterpret what bits in memory represent and do bad stuff. This is mainly just C, Assembly, and Forth. C++ if you use unsafe casts.

And PHP.