2008-03-27

How do you counter an Acid(3 test)? With a Base(3 test)

Lately, the WebKit and Opera devs have been racing to see who can make their browser pass the Acid3 test first, or at least be the first to get 100/100 (for more details on why this is not the same thing, please visit the earlier Wikipedia link). Notably absent from this entertaining contest was Firefox. If you're saying "Hold on! They're probably just trying to get Firefox 3 out the door," you're right... sort of. While that is supposedly the main argument put forward by shaver in his recent blog post on Acid3, it takes less than 2 paragraphs to completely exhaust that idea and 7 (mostly massive) paragraphs to bag on the Acid3 test for focusing on the wrong things. Meanwhile, Rob Sayre dismisses the test in his blog post on the subject without even offering the excuse (which I believe is totally valid) that Firefox 3 is the top priority. So, since it seems to be the consensus among Firefox devs that Acid3 focused on the wrong things, why don't they publish a test that they think focuses on the right things? Dan_Farina over at the programming subreddit suggested this "Base3" test and I think he's right.

Back to flipping out...

2008-03-20

Sneak Attack: More Performance Tips from YAHOO!

Back to flipping out...

2008-03-05

C/C++ Programmers

Thanks for suffering so I don't have to. - paulzork said it on the programming subreddit about C/C++ programmers, and I don't think I've ever seen a better summary of my feelings for C programmers.

Back to flipping out...

2008-03-04

JavaScript Idioms - Copying an array

Ever see a block of JavaScript that looks like this?


var myArray = [];
for (var i = 0; i < source.length; i++) {
    myArray[i] = source[i];
}

That's the popular way to copy the elements of one array (note the lack of capitalization) into a new Array (note the capitalization - we'll get to this in a minute). I wasn't really a fan, at first, but it's almost as pervasive as

while(*dst++ = *src++);

in C, so eventually I decided to stop worrying and love the bomb. Basically, JavaScript will automatically grow your Array for you, so you can dispense with all the sizing you might expect when using something called an Array.

Now for the notes you took on capitalization. Not everything that acts like an array in JavaScript is actually an Array. One example is the arguments property available to Functions. If you happen to need the stuff in arguments as an actual Array (because you want to use it as a key for a map/dictionary/hash, let's say), you will find yourself writing some code like that above. Just remember that sometimes stuff is "Array-like" without actually being an Array, because it can really bite you if you're not careful.

Back to flipping out...