News for hackers. Stuff that matters.
Re:Javascript is good enough by tlrobinson on Saturday January 31, 2009 @04:02PM (#460039)
But the one the OP places the greatest emphasis on - that all hash keys are strings - only caused us trouble once, and in that case we found a simple workaround. I'm curious: have other people here experienced that limitation of JS as a fundamental obstacle?

Yes, any time you want to use a non-primitive type (strings, numbers, etc) as a key to hash map.

But we solved it in Objective-J by automatically giving each Objective-J object a unique "hash" value.

(of course you could do something similar in plain JavaScript, but you'd have to implement it yourself)

Re:Javascript is good enough by maxwell on Saturday January 31, 2009 @10:48PM (#460483)
This is one of those features that I've read Lua has and JS doesn't that sounds really good in theory. But I haven't ever run into a situation where I've wanted an index other than a number or string. It's probably just a blub paradox though; I'm curious, in what situations are other values particularly useful as keys?
Re:Javascript is good enough by boucher on Sunday February 01, 2009 @03:57AM (#460715)
Any time you ever need to map an object to another object, you need this functionality.

Without a memory address, object's don't have any other unique values associated with them. It's actually a pretty fundamental problem.

Of course, like most things wrong with javascript, you can fix it if you work for it. Objective-J fixes all the things we had problems with, and this is one of them. A lot of things in Cappuccino would not be possible without the hashing feature Tom mentioned.

As a hash table, JavaScript objects are pretty awful. You can't get a count of objects unless you literally count all the keys. And you can't iterate over the keys if anyone else has added anything to the Object prototype.

Cappuccino has a proper hash table, CPDictionary, which solves both of those problems. There's a lot of other data structures that address some of the author's listed concerns.

Re:Javascript is good enough by LogicHoleFlaw on Saturday January 31, 2009 @11:19PM (#460508)
In Lua I've done stuff like maps of functions to tables of functions for permuting different methods of computation... kinda wacky but it does what I need.
Re:Javascript is good enough by gruseom on Saturday January 31, 2009 @04:33PM (#460080)
Ah, I get you. We haven't needed that yet.