Re:Software in 2014
by ceautery on Thursday January 09, 2014 @07:08AM
(#7029980)
"JavaScript is horrible."
No, it's not.
[ Parent
| on HN ]
Except it is, because your code doesn't work:
> [10, 1, 5, 1, 10, 10, 1, 5, 5, 5, 10].sort(byNum)
> [10, 10, 5, 1, 10, 1, 1, 5, 5, 5, 10]
The right way is > function byNum(a, b) { return a - b; }A bug in my code doesn't make javascript horrible, it makes me horrible for rushing to illustrate a point instead of just harrumphing internally and finishing my coffee.
Good catch.
Re:Software in 2014
by Dirlewanger on Thursday January 09, 2014 @07:50AM
(#7030134)
Writing your own method to solve a problem every other language does out of the box is missing the point...
True, JS doesn't ship with a large standard library. But that has turned out to be one of its greatest strengths and a key reason for it's runaway success.
> runaway
See "runaway chain reaction".
I'm not following, is this just snark or am I missing a point?
Re:Software in 2014
by kelseyfrancis on Thursday January 09, 2014 @08:57AM
(#7030444)
The point is not that it's impossible to numerically sort an array of numbers in JavaScript; it's that calling the sort function on such an array doesn't do that. That's a surprise to most developers, I'm sure, and surprises in languages and libraries are bad.
that looks pretty horrible if you ask me