The Antiviral Effect
bemmu.posterous.com
bemmu.posterous.com
Still, I'm glad you were able to catch it in time and reverse the trend.
The great thing about losing potential revenue is that there is an infinite amount of it out there. I know that is cold comfort but it helps me sleep soundly at night, in the face of some bugs which have been fairly costly.
I caught a subtle one last night which would have been a real, real doozy. I was busy writing additional documentation for my A/B testing framework and then wondered, hey, why does this thing I'm recommending sound very different than what I remember actually implementing?
Then I thought "No, wait, that's preposterous. If I had actually implemented that, I would have gotten subtly incorrect garbage data which would have... passed... all my... tests... until deployed live... oh dear."
On the plus side, this time it only cost me a weekend full of analytics data rather than $10,000, but if I had started "improving" my site based on the borked data shudder.
BTW: I actually think an array changing its behaviour is an unreasonable change - for languages like C and Java - but a reasonable one for dynamic languages. It reminds me of a comment someone made about the "C# and Java Weekday Languages, Python and Ruby For Weekends?", that C#/Java are less fun to code in, but more fun to maintain, and the same features are responsible for both effects.
I wonder what you could have done to find the bug before it was a serious problem? Most server side errors are easy because you can configure alert emails. Subtle data corruption or client side bugs are much harder to pin point as they manifest much further down the pipe in unintuitive ways.
Subtle data corruption bugs aside, is there someway to handle client side bugs? I'm no Javascript expert, but I'd imagine there has got to be a way to register a global on-error handler and post bug reports to the server? Any expert insight here?
Example:
var arr = [0,1,2,3,4,5]; for(var p in arr) { console.log(arr[p]); } Array.prototype.foo = "bar"; for(var p in arr) { if(arr.hasOwnProperty(p)) { console.log(arr[p]); } } for(var p in arr) { console.log(arr[p]); }
If you run this in firebug's console, you'll notice that the first two loops work as expected, even after changing the prototype of the Array object. The third one, however, will spit out "bar" as well.
JSLint can be mean to your code, but it helps catch an enormous amount of small bugs like this caused by JS's warts.