Sunday, September 13, 2009

Bug of the Day, or, How I Escaped from the Evil Empire

I saw the bug description and my heart sank.  It was that dreaded two-letter word: IE.

I do not own a Windows computer, which means that I would have to borrow one, and worse, that I'd have to debug remotely. Also, debugging on Internet Explorer is a pain in and of itself.  Only Firefox has historically provided good support for debugging JavaScript.

Before I actually borrowed the Windows, though, I looked at the bug again.  The bug said that the text "null" appeared under the chart image on the examples page in IE.  I thought to myself, "Oh, the image URL string that's supposed to be printed under the chart is coming up null in IE."  To verify this, I went to our QA engineer and asked her about the bug.

"So the image URL is coming up null in IE?" I asked.

"What image URL?" she asked.

Apparently, there was no text at all under the chart image in Firefox, Chrome etc.  This looked fine to the QA engineer, but I knew that that was incorrect as well.  In fact, it probably meant that the bug was really one unified cross-browser bug; the method that was supposed to return the image URL was returning null, and the only difference was that IE printed the URL as the text "null" and Firefox didn't print it at all.  In this case, the behavior of IE was actually more helpful.  Imagine my relief!  In all probability, I wouldn't have to deal with IE after all.

So I went back to good old Firefox and opened the examples page.  As soon as I looked at the page source, it was clear that the example was getting the image URL with the wrong signature -- a signature I'd used previously but had since abandoned.  Apparently, since I'd changed the signature, I hadn't even opened the examples page.  I just ran the tests and submitted the code without looking at what the code actually did.

That was kind of embarrassing, but in terms of present work, it was great!  It meant that the problem was in our private examples page, not in the public API code I'd written.  All I had to do was fix the function signature in the example and the "bug" would be fixed.

However, when I fixed the signature, I was in for another surprise; an unpleasant surprise.  The URL showed up, but the chart was gone!  How could printing a URL string make the chart disappear?  I tried printing "hello world" instead of the URL, which, of course, had no effect on the chart.  After messing around for a few minutes, I realized what was going on.  The code to compute the URL was actually clearing the chart's container!  That means that any call to retrieve the image URL would kill the chart in the process.  The entire image URL feature I'd implemented was worse than worse than useless: it was thoroughly evil!

Once I discovered this, it was very easy to fix: I just had to save the image URL instead of recalculating it.  This was something I'd been planning to do anyway, but I probably wouldn't have gotten around to it before the release.

In conclusion, an evil bug in my production code had been hiding behind a bug in my example code.  And it would have gotten away with it, if it hadn't been for the vigilant eye of our QA engineer, and a little browser they call Internet Explorer.


Tuesday, September 8, 2009

The Subtlest Diaper I've Ever Seen

We usually buy Pampers.  Every once in a while we buy a local brand called Titulim.  The design on the Titulim diapers doesn't have any text on it.  It has a pattern of medium-size shapes in subdued blue and purple, like wallpaper.

For a while, I didn't pay much attention to what the different shapes represented.  About a year after moving to Israel, I reflected a little bit on the shapes themselves.  There are six shapes repeated on the diaper: butterflies, balls, bears, baloons, blocks, and stars.

Presumably, the B was chosen because it's the first letter of the word "baby", though of course babies do not appear on the diaper.

The burning question, of course, is what are the stars doing there?  Is the designer going for a higher order of subtlety by including a misfit?  "One of these things is not like the others?"

I cheated by not mentioning something about the stars: they come in pairs (one bigger and one smaller), which suggests that together they form a binary star.

Who designed this thing, an English professor who didn't get tenure?



Monday, September 7, 2009

Who Will Laugh?

Recently I wrote a post on the Bruria story, so I decided to write a post about my favorite example of traditional Jewish humor.  This has been on my toblog list for a while.  Besides, Rosh HaShana is coming.

Where did Yitzhak Avinu (known to some as the Patriarch Isaac) get his name?

This will be no mystery to most of my Dear Readers.  Yitzhak means "he will laugh", and he was called Yitzhak because both his parents laughed at the prophecy of Yitzhak's birth.  Avraham's wife, Sara, was too old to have children, and yet Hashem (known to some as God) told them (individually) that she would have a son.  The reaction of both was laughter.

Avraham and Sara laughed at the prophecy because they couldn't beleive it.  Why do you laugh at something you can't beleive?  You can't believe it, so you assume that the speaker is "pulling your leg", "putting you on" -- that the speaker is joking.

Sara, of course, subsequently had a son, so it was clear to Avraham and Sara that they'd been wrong; Hashem had been serious.  Until, a few years later, a funny thing happened.

"Hey Avraham," Hashem said.  "Remember how I said that Sara was going to have a son?"

"Of course," Avraham said.  "At first I thought You were just joking.  But then she did have a son, and isn't he a sweetheart.  Thanks a million."

"Actually," Hashem said, "I was joking, though maybe not the way you thought at first."

"What do you mean?" Avraham asked.

"Now," Hashem said, "you have to kill him."

If Avraham had been a Shunamite woman, he would have said, "Didn't I tell You not to f*** with me?"  But he was a bit more circumspect, so he did as he was told.  Then, when the knife was at Yitzhak's throat, Hashem said:

"Just kidding!  Ha ha."

And that is how Yitzhak got his name.

Funny, isn't it?



Sunday, September 6, 2009

Godel Escher Bach Rashi

Rashi's Bruria story is pretty wild, isn't it?  If you can, I suggest reading the original Hebrew (the citation's in the wikipedia article).

Until yesterday, my reaction to this story was just that I found it offensive.  But yesterday, my friend Moshe Noiman challenged me to look at the story a different way.  He asked me, what is the moral of the story?  After thinking about it that way for a little while, it hit me like a ton of bricks.  The moral of the story is very simple: maybe women are not so light-headed after all.

Think about it.  Rebbe Meir didn't intend to kill his wife, he just wanted to have some fun at her expense.  But Bruria took things much more seriously than he expected.

Note that neither Rebbe Meir nor his unnamed student -- the men of the story -- committed suicide, though their misdeeds were surely, from a technical standpoint, just as serious as Bruria's misdeeds.  By playing their little practical joke, the men of this story took very lightly something that the reader probably realizes should be taken a bit more seriously.

The story operates on two levels; it's a second-order narrative.  Rebbe Meir and his student set out to prove that women are light-headed (relative to men).  But they become part of a bigger story which proves the opposite, that men are light-headed relative to women.  Overtly, the story buttresses the Talmud's dictum that women are light-headed; covertly, the story satirizes and undermines that very dictum.

Tuesday, September 1, 2009

Nice Try, but The Incredibles Was Better

Yesterday I finished watching The Dark Knight.  If you haven't seen it yet, stop reading now, because I'm going to give away the ending.

The movie made me very sad.  I was sad that Rachel and Harvey died.

I think that part of the reason it made me so sad is that the plot was sloppy.  The death of a fictional character can be poignant, moving, even cathartic, if the character is killed by a good, solid plot, like Leonard Bast in Howards End.  When characters I like are killed by a sloppy plot it just gets me down.  As if Rachel and Harvey died in vain, if you know what I mean.

I was also really sad that Heath Ledger died.  His performance as the Joker almost lived up to the hype.  But the movie as a whole did not.  Sure, a lot of things were very well done, but based on the hype, I was expecting The Great American Superhero Movie.