Aug 31 2008

Not from the Benevolence of the Pilot

Every time I have doubts about how safe flying is, I think to myself:

It is not from the benevolence of the pilot that I expect not to die after crashing into a mountain, but from the pilot’s regard to his own interest.

It amazes me how this line of reasoning seems to never enter into the minds of those whose fear of flying is so great that they simply refuse to board planes. It is as if they genuinely believe that the pilot, who flies many times each week, is not concerned with keeping himself alive.

I suspect the only relevant criterion for selecting potential pilots is an estimate of their disposition to suicidal behavior.


Aug 30 2008

Negative Items Left to Delete under Mac OS X Leopard

Until today I’ve felt that, at this point, Leopard has been patched enough to be relatively bug free. While transferring files across my home network today I changed my mind, because I found that the number of files left to delete that’s shown in progress dialogues can become negative. You can see what I mean below:

-2593_Items.jpg

And just to make clear that the first number isn’t a one-time fluke, here’s another shot of the same progress dialogue a second later:

-3697_Items.jpg

I’m not entirely sure what caused the negative count: most likely it was the very large number of small files that had to be deleted. I’d bet that the number was originally underestimated when the delete operation began, and that, when more files were found later, this took the count of remaining files beyond 0 into the negative integers.

Personally, I find this a little worrisome.


Aug 29 2008

Shipping American Products to Europe

My friend Harek and I were recently discussing the obvious and not-so-obvious reasons why both Amazon’s Kindle and Amazon’s considerable repertoire of e-books are not available for sale outside of the U. S.. I noted that there are many legal hoops one must go through before selling a product in the countries of the European Union, and that these hoops were likely sufficient to explain Amazon’s choice of first entry markets.

While reading “Blown to Bits,” this suspicion of mine was reinforced by the following passage:

National and state borders still count, and count a lot. If a book is bought online in England, the publisher and author are subject to British libel laws rather than those of the homeland of the author or publisher. Under British law, defendants have to prove their innocence; in the U.S., plaintiffs have to prove the guilt of the defendants.1

This tidbit relating to the differences between American and British libel law is exemplary of a general pattern: American products are often not available in Europe because American businesses fear the unfamiliar and sometimes incomprehensible laws of European governments. If Europeans want freer access to American goods, they will need to make sure that they will not punish Americans for selling goods that they can sell without fear in the States. In the opposite direction, but following precisely the same pattern, American children will have access to Kinder Eggs and other wonderful European products just as soon as America repeals some of its excessive child safety laws.

  1. Hal Abelson, Ken Ledeen and Harry Lewis : Blown to Bits : Preface

Aug 25 2008

A Lesson in Consequentialism for Jenny McCarthy

I generally take the strong consequentialist position that a person who causes A, which later causes B, must be held accountable for B, regardless of whether that person intended to cause B. In short, I broadly claim that factual casuality is moral responsibility.

Therefore, if you stop your child from being vaccinated, I would assert that you are directly to blame for the possible death of your own child and also for the possible deaths of any and all children infected by your child. Moreover, if you advocate refusing vaccinations, you are morally responsible for the deaths of every person who follows your suggestion.

Under this analysis, it looks like I’ll soon be able to claim that Jenny McCarthy is a murderer, because the once eradicated disease measles has started to make a come back in the U. S. recently.


Aug 23 2008

Why Shouldn’t I Put You in Jail?

This snippet of court proceedings is amazing:

“Why shouldn’t I put you in jail for contempt today?” Booth asked. “I told you twice.”

“I’m sorry,” Arnold said.

“No, you’re not,” Booth said. “I told you twice. I even fined you for being in contempt. Why shouldn’t I throw you in jail today? You apparently don’t care about the court’s orders.

“I forgot,” Arnold said.

“How could you forget?” Booth said. “No, seriously, how could you forget? It’s a complete disregard of court order. Complete. You should go to jail today, and you’re going.”1

I particularly like the fact that the judge used the words, “no, seriously.” For those who don’t want to read the original article, the judge was so incensed because the defendant repeatedly wore short shorts during her trial.

  1. Bluegrass Beat : Judge jails woman for wearing short shorts

Aug 21 2008

G.K. Chesterton

After spending more than two years on the list of authors I want to explore, I’ve finally begun reading G. K. Chesterton’s “The Man Who Was Thursday.” There is a brilliant passage at the start that I plan to quote in the future, but for now I thought I should quote this wonderful aphorism of Chesterton’s, which is cited in Leonard E. Read’s I, Pencil:

We are perishing for want of wonder, not for want of wonders.1

  1. G. K. Chesterton

Aug 20 2008

No One Will Ever Want a Personal Computer

I don’t care how many movies are available to me. As my personal taste as a customer, I want to watch the new stuff so whether we have 10,000 movies or 200 movies doesn’t matter if I don’t want to see any of the movies that we have . . . our assortment is heavily weighted toward newer releases and mainstream staple titles.1

The quote comes from an interview with Blockbuster’s CEO, who evidently finds Netflix’s success very confusing. Every one of his comments reminds me a great deal of the infamous claim by Ken Olson, the President of Digital Equipment Corporation, in 1977, that,

There is no reason anyone would want a computer in their home.2

It’s rare that you get a chance to watch a CEO of a once thriving corporation publicly reveal his inability to adapt to a changed market. There is a sort of schadenfreude joy to it, along with a reminder that no monopoly is permanent under capitalism.

  1. Jim Keyes : Wired.com : Blockbuster CEO ‘Confused by Fascination’ With Netflix
  2. PiPrograms : Famous Last Words

Aug 20 2008

Why You Shouldn’t Be Clever

Today I started reading the Ruby Snips website, which has a pretty good sample of interesting snippets of Ruby code on it. I was particularly intrigued by the following snippet from a post on Prime Numbers dating back to March 23rd, 2007:

1
2
3
4
5
class Fixnum
  def prime?
    ('1' * self) !~ /^1?$|^(11+?)\1+$/
  end
end

At first, I was convinced this code was broken. Before I had given much thought to the algorithm, I was ready to assume that the “prime?” name was a misnomer: I assumed the code was actually testing for members of a specific class of palindromes. After a minute or two, I pieced together what was really happening when testing a number:

  1. The number, n, is expanded into a string of 1’s of length n.
  2. The string of 1’s is testing using a regex with back-references that finds the presence of a repeated divisor, a technique that works because a string of length a * b = n is composed of b copies of a string of length a.

At that point, I began to marvel at the simplicity of the algorithm relative to the obscurity of the code. And while I was so amazed by this, it occurred to me: this is an absolutely terrible way to test for primality. Because you have no control over the loop bounds for the regex, you effectively test every number up to n as a possible divisor if n is a prime. But you really only need to test up to the square root of n to determine if n is prime. So your code runs for the square of the time it should run. And the expansion of n into a string, at least theoretically, requires exponentially more space than an integer expressed in binary would. This seemed like one of the worst possible ways to test for primality I had ever seen.

Still, I wanted to verify this empirically as well as theoretically, so I typed in

1
399839483.prime?

during an IRB session. The CPU and memory usage were absurd for a primality test on such a small number. I didn’t even bother letting the code complete after a few seconds of the watching interpreter hanging there, silently wasting CPU cycles. In contrast, the simpler, clearer code,

1
2
3
4
5
6
7
8
9
10
class Fixnum
  def prime?
    (2..Math.sqrt(self).to_i).each do |i|
      if i * (self / i) == self
        return false
      end
    end
    return true
  end
end

runs fairly quickly.

The lesson I think everyone should take from this is a simple one: don’t be clever when writing code. At the very least, don’t be clever in the way the author of this snippet was. Your code is likely to end up being unclear, slow and wasteful with memory.

Perhaps I should be clearer about the problems of cleverness. Clever code is a mistake; clever algorithms are wonderful. Quick sort is a clever algorithm that always confuses me until I think carefully about it — and then I marvel at its superiority over other less efficient sorting algorithms; this snippet is a mediocre algorithm written in a style of code that’s needlessly confusing.


Aug 18 2008

Not Exactly a Comforting Thought

From an article on The Volokh Conspiracy describing the role and traits of swing voters in the U.S.:

The voters who know the least are the ones who tend to determine electoral outcomes.1

  1. Ilya Somin : The Volokh Conspiracy : The Political Ignorance of Swing Voters

Aug 18 2008

Heavy Metal in the Islamic World

Here is an absolutely amazing article on heavy metal bands in the Islamic world.