![]() |
![]() |
![]() |
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-07-29... so many to choose fromWhat if you gave a standard and nobody came? Standards are a good thing, and open standards are even better, but do I really have a standard just because I say so? Some of the most successful standards are de facto standards — standards that have become so because a product has been accepted by the market and become the paragon against which others are judged. Linux could not exist without Unix having first established a de facto standard. On the other hand, proprietary standards can fail to take hold because the market does not accept them. The classic example here is Beta vs. VHS — it is widely accepted that despite Beta being a better quality format, Sony's refusal to open (even license) its standard, let VHS dominate in the marketplace. Postscript and Java are interesting standards to compare. Adobe has retained control of the Postscript standard, but because Postscript has to have an interface to page layout programs that is well-specified, third parties have been able to create Postscript emulators, competing with Adobe's proprietary implementation. Adobe has retained market share by continuing to provide value — Adobe's engine remains the touchstone against which all other emulators are judged. Sun has waffled on whether to relinquish control of Java to ECMA in an attempt to gain greater acceptance while preventing the divergence that plagued Lisp and Unix in the early 70's. Sun has had less success than Adobe in licensing "true" Java, perhaps because the value is less clear. The question is: when developing a new product, at what point do I want to standardize it? 2003-07-24Safar-as-I's concernedSafari bugs that are impeding me: Setting Here is a simple example that works as expected in Camino (Mozilla). Web Ring is an actual application that I am working on that demonstrates the 'only loads once' effect. Comments
Hey PTW, just read your lamment about frames. Have you tried document.getElementById('frameID').src = url? That should work for you and I believe it is the preferred method. Cheers! 2003-07-29 16:22 | Shaun Inman
Indeed it does. Thank you. I had been led to believe the former was preferred by pp:k ( http://www.xs4all.nl/~ppk/js/index.html?/~ppk/js/iframe.html ), but he does mention this technique also. 2003-07-29 17:25 | P T Withington
2003-07-21Royale FUD1Macromedia's Royale promises to be, someday, everything that Laszlo Systems2 is today. LZX is an object-oriented programming language expressed in XML and Javascript. Application source files are text-based, meaning they can be managed by any IDE and source control system, and projects can easily be developed by teams. The Laszlo foundation classes are a suite of UI objects and behaviors providing a substrate for rich internet apps, including back-end database connectivity. The Laszlo presentation server is a JRE servlet that is deployed on a J2EE application server. The presentation server compiles your LZX source to SWF so your application can be delivered to any platform where the Flash player is present (5.0 player or better). Laszlo lets you build desktop-level power into applications that can run in any web browser. 1. FUD: Fear, Uncertainty, Doubt. A Marketing technique originated by IBM, perfected by Microsoft, and now employed widely to stifle innovation by sowing rumors when you don't have a competitive product. 2. Yes, I work for Laszlo, so I might be a little bit biased. Decide for yourself. Check out the demos, download the free developer version. Give it a try. 2003-07-18Is it a sign?Walking to my train today, stopped to drop my spare change in a coffee cup. The holder is wearing a Macromedia polo shirt. What does it mean? 1998-10-16Garbology"noun, social science: the investigation of the refuse discarded by a society as part of the study of that society. c 1970s: from GARBAGE" |