News for hackers. Stuff that matters.
Re:JavaScript: The Curious Case of null >= 0 by gruez on Saturday September 09, 2017 @09:48AM (#15207066)
Done right (like in python), it's not so bad.
Re:JavaScript: The Curious Case of null >= 0 by zzalpha on Saturday September 09, 2017 @09:54AM (#15207092)
I really wish the industry settled on terms for this stuff but alas...

The difference is python is strict about its types and doesn't do automatic coercion. So at least you get type errors at runtime and not magic implicit behaviour.

That said, even Perl did this better (less magic and surprises)... JavaScript is like a language intentionally designed to surprise the developer. Half the time I feel like it's a practical joke that someone accidentally took seriously.

Re:JavaScript: The Curious Case of null >= 0 by alangpierce on Saturday September 09, 2017 @10:27AM (#15207219)
> I really wish the industry settled on terms for this stuff

I've pretty consistently heard "strong typing" to mean that the language avoids coercing between types, and "static typing" to mean that types are known at compile time. So JS and Python are both dynamic typed, but Python is (more) strongly typed and JS is (more) weakly typed.

https://stackoverflow.com/questions/2690544/what-is-the-diff...

Re:JavaScript: The Curious Case of null >= 0 by mikebenfield on Saturday September 09, 2017 @12:19PM (#15207731)
Yes, I've always understood this to be the correct terminology, but unfortunately in informal discussion among non-academically inclined software people, people use the terms wrong more often than they use them right. You get lots of people saying C is strongly typed (it certainly is not) and something like Scheme is weakly typed (it certainly is not).
Re:JavaScript: The Curious Case of null >= 0 by zzalpha on Saturday September 09, 2017 @12:37PM (#15207804)
If you're really want a fun time, try having a conversation about "duck typing" some time... it was around the time that term became a thing that I realized no one seems to agree on what all these terms mean.
Re:JavaScript: The Curious Case of null >= 0 by marcosdumay on Saturday September 09, 2017 @02:50PM (#15208559)
Using "strict" vs. "non-strict" and "static" vs. "dynamic" will increase a lot the odds of people understanding.
Re:JavaScript: The Curious Case of null >= 0 by TheRealPomax on Saturday September 09, 2017 @01:43PM (#15208155)
the problem is there is no "right" until you define what right means, which is where the spec comes in. These results are "right", if unexpected, and the true issue here is of course not so much the mathematical results between the three tests, but the fact that JS gives you the freedom to compare anything to anything, irrespective of whether that comparison makes sense at all. Python allows this in a few places, too, with equally bizarre results (see another comment that highlights a few of them).

While tempting to do so, thinking of >= as implying "> or ==" is simply not true in any language that performs type coercion to get around type incompatibility issues.