Hacker News new | comments | show | ask | jobs | submit login

Everything looks great, other than the fact I'm still forced to use a broken language to interact with shiny new APIs:

https://gist.github.com/4471029

Then you want me to manipulate binary data with an array implementation this crappy?




So it uses lexicographic sort by default, just pass a custom comparator no?

https://gist.github.com/4471254


or if he doesn't even feel like passing a custom comparator every time and just wants to default to increasing numerical order:

(function(){var a=function(a,b){return a>b},b=Array.prototype.sort;Array.prototype.sort=function(){return b.call(this,a)}})();


I'm aware of the solution. What I'm disputing is why sort does the least obvious, stupidest thing I can think about by default - specially since numerical is equivalent to alphabetical for the ASCII set.


Arrays in JavaScript are instances of the Array object

Two different instances are not equal to each other


Yes, I get the idiossincracies. Triple equal operator also returns false.

What I don't get is how is it acceptable this language has the largest installed base in the world and you have to write boilerplate just to equality test two arrays.


> how is it acceptable? Because developers feel that it is and have done so in past. Because things that required and unavailable have been put down in libraries that developers can import and utilize. Because there are many libraries that compete against each other to provide better interfaces for their users. Because they are used very widely and very successfully. Because it's simplicity has made it usable among the masses who may not have otherwise participated in content creation on the web if CS101 was a requirement. Because its benefits have outweighed its faults. Because when people suggest alternatives (Dart?) they realize that they need to make them compatible with JS because it is not only popular but also quite efficient now.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: