News for hackers. Stuff that matters.
Re:“It is never a compiler error” by mar77i on Wednesday November 15, 2017 @04:48AM (#15702646)
What an awful gem of surprising by design.

Definitely going to add this to my contempt for javascript list.

Re:“It is never a compiler error” by fenomas on Wednesday November 15, 2017 @05:09AM (#15702717)
It's the worst option except for all the others, I think. JS arrays can contain anything, so if the default behavior was to compare elements as numbers, sorting an array containing mixed types would have unpredictable results (because of comparisons to NaN, etc).

Naturally things are only weird for untyped arrays - calling sort() on e.g. an Int32Array does what you'd expect.

Re:“It is never a compiler error” by sullyj3 on Wednesday November 15, 2017 @05:34AM (#15702801)
Python throws an exception for incomparable types. I guess that's not really practical on the web.
Re:“It is never a compiler error” by TremendousJudge on Wednesday November 15, 2017 @09:11AM (#15703801)
why is it better to silently fail than to throw an exception simply because it's running on a web browser?