![]() |
![]() |
![]() |
2003-08-12Flash HashThe new Flash 7 beta demonstrates a significant performance improvement. Presumably some of that improvement comes from improving an algorithm that must be central to any Javascript virtual machine: looking up Object members. Objects in Javascript can have members with any Javascript string as the member name. Most implementations will use a hash table to implement Objects, where the hash key is the member name and the hash value is the value corresponding to that member.
Arrays in Javascript are really just Objects that happen to have members with names like Implementing Array’s efficiently must be tricky, because programs will typically ask for array members using numeric indices, but Javascript semantics state that they must behave as if the numeric index was converted to a string first and then used to look up the member. Furthermore, you are allowed to add members to an array with non-numeric indices, so you can’t specialize your hash table to only support numeric indices. Clearly, you’d like to avoid the overhead of converting to a string if you can. One way I can think of doing that would be to have a clever hash algorithm that hashes numbers and the string representation of a number to the same value, then you can delay the number-to-string conversion until you have a key to compare to.
I’m thinking that Macromedia may have an optimization something like that in the Flash 7 player, because of the following bug that I have found. If I set any array to have an element at If you have Flash 7 beta installed, you can see for yourself: Flash 7 Bug Here’s the source code for this demonstration: mylist.addItem("Create an empty array: var crud = new Array;"); var crud = new Array; mylist.addItem("Store a value at '-': crud['-'] = 'foo'"); crud['-'] = 'foo'; mylist.addItem("Create an array of one element: var ary = [ 'one' ];"); var ary = [ 'one' ]; mylist.addItem("What is at ary[0] now?"); var j = '0'; mylist.addItem('ary[' + j + '] => [' + typeof(ary[j]) + ' ' + ary[j] + ']'); mylist.addItem("What is at ary['-'] now?"); j = '-'; mylist.addItem('ary[' + j + '] => [' + typeof(ary[j]) + ' ' + ary[j] + ']'); mylist.addItem("What are all the elements of ary?"); for (var i in ary) { mylist.addItem('ary[' + i + '] => [' + typeof(ary[i]) + ' ' + ary[i] + ']'); } 2003-08-07Voting rightOur right to vote has two important principles: anonymity (so your vote cannot be coerced) and accountability (so your vote cannot be miscounted). Paper ballots work because the ballot is accountable (it is a physical token that represents your right to vote — counted when you identify yourself as a voter, counted when you vote, and counted when the vote is tallied), and the ballot is anonymous (you mark your ballot privately, the marks are tallied separately from your identity). There is a possibility for fraud: extra ballots could be introduced, or ballots not counted — this is controlled by comparing the count of voters to the count of ballots; or the votes on the ballots could be incorrectly counted — this is controlled by recounting the physical ballots if something seems amiss. So-called “electronic voting” threatens this system because there is no physical representation of each ballot. (Actually, there is a physical representation in the electronic charge of certain atoms in a RAM chip or the magnetic polarity of crystals on a hard drive; but these are hardly inspectable in the clear fashion that a physical paper ballot is.) Independent of the issue of computers being complex and unreliable, without a physical token representing each vote that can be inspected directly by humans, there is tremendous opportunity for voter fraud, both intentional and unintentional. If you want to know more about the issues surrounding electronic voting machines, you should read this article by Dr. Rebecca Mercuri, professor of computer science at Bryn Mawr. If you want to be frightened, read Lynn Landes' page on Voting Security. Two recent events prompted me to think about this issue: First, a report in the Boston Globe regarding a push to use touch-screen voting machines in Massachusetts. Thankfully, Secretary Galvin is taking a careful approach. Second, a report from Scoop regarding Dr. Mercuri being ejected from an elections conference. Now, why would they want to do that? 2003-08-05John Peter ZengerToday is the anniversary of the verdict in the trial of John Peter Zenger, considered by many the germ of our right to freedom of speech. The outcome of the trial hinged on the (today) little-known principle of Jury Nullification. The jury's verdict of “not guilty”, against the judge's instructions, effectively nullified the application of the English seditious libel laws in the Colonies, paving the way for our freedom of the press. [On a personal note, Lewis Morris, who was removed from the case by the royal governor, is an ancestor of my spouse. His great-grandson, Gouvenor Morris, penned the preamble to the constitution and noted the influence of the Zenger trial on our first amendment: “The trial of Zenger in 1735 was the germ of American freedom, the morning star of that liberty which subsequently revolutionized America.” [A full account of the trial by Douglas Linder, Professor of Law at University of Missouri-Kansas City Law School is available at Zenger Trial.] 2003-08-04Why Fi?Tech Superpowers, the folks who bring you Newbury Open — free wireless internet access on Newbury Street, have an interesting demo at Boston's South Station. The have set up a wireless internet “bubble” that lets travellers get a glimpse of what it might be like to have free wireless access in the station. Unfortunately, they inform you, the “powers that be” are holding out, thinking that someone is actually going to pay them to have the right to the wireless airspace in the station (presumably because they will then charge people to access the internet from the station). Wrong business model if you ask me. Wireless internet access should be like Muzak or plant services. They enhance the value of your space by making customers linger and spend more money… Who are these mysterious “powers”, and how do we get though to them? |