Eat, drink, and be merry

Almost every bit of health advice I’ve heard has been contradicted. Should you eat more carbs or fewer carbs? More fat or less fat? Take vitamin supplements or not? It reminds me of this clip from Sleeper in which Woody Allen wakes up after 200 years of suspended animation.

Offhand I can only think of a couple things on which there seems to be near unanimous agreement: smoking is bad for you, and moderate exercise is good for you.

Here are a couple suggestions for evaluating health studies.

Be suspicious of linear extrapolation. It does not follow that because moderate exercise is good for you, extreme exercise is extremely good for you. Nor does it follow that because extreme alcohol consumption is harmful, moderate alcohol consumption is moderately harmful.

Start from a default assumption that something natural or traditional is probably OK. This should not be dogmatic, only a starting point. In statistical terms, it’s a prior distribution informed by historical experience. The more a claim is at odds with nature and tradition, the more evidence it requires. If someone says fresh fruit is bad for you, for example, they need to present more evidence than someone who says an newly synthesized chemical compound is harmful. Extraordinary claims require extraordinary evidence.

Related posts

Read history and fly an airplane

The “About the Author” page at the end of Programming in Emacs Lisp says

Robert J. Chassell … has an abiding interest in social and economic history and flies his own airplane.

I love the childlike element of that bio. I could just imagine a kid saying “When I grow up, I want to read about history and fly my own airplane!” The bio is more about what the author enjoys than about how he makes his money. Maybe more bios should be like that.

The bio starts out by saying that Chassell speaks about Emacs and software freedom. I thought that was just to establish his bona fides for writing about Emacs Lisp, but his Wikipedia page says he’s a full-time speaker, so perhaps this is how he supports himself. I would not have thought that was possible, but good for him. Apparently he earns his living by talking about something he values.

Update: As suggested in the comments, perhaps Chassell’s livelihood does not come from his speaking. Maybe he has (or had) another career and chose not to include it in his bio. Or maybe he doesn’t need to earn a living from his speaking. In any case, it sounds like he’s doing something he loves and his bio focuses on that.

No Silver Bullet

Mike Swaim gave a presentation today entitled No Silver Bullet, an allusion to Fred Brook’s classic essay by the same title.

Mike discusses the pros and cons of the following software development techniques:

  • High level languages
  • Object oriented programming
  • Declarative languages
  • Functional programming
  • Data oriented design
  • Metaprogramming
  • Static typing
  • Duck typing
  • Garbage collection
  • Allocating on the stack
  • Tail calls
  • Resource acquisition is initialization
  • Symmetric multitasking
  • Heterogeneous multitasking

There’s a nice collection of links at the end of each section.

Update: Unfortunately the slides are no longer available.

Superheroes of the Round Table

The other day I was browsing the Rice library and ran across a little book called “Superheroes of the Round Table: Comics Connections to Medieval and Renaissance Literature” (ISBN 0786460687). It’s about how literature has influenced comic books, and how comic books shed light on literature.

I don’t know much about comic books, or about medieval and renaissance literature, but it’s fun to see someone draw them together, especially since the former is considered low culture and the latter high culture. It reminds me of Scott McCloud’s book Understanding Comics: The Invisible Art, a serious book about an art form that isn’t often taken seriously.

I’ve only skimmed Superheroes of the Round Table, but it looks like a fun book. It draws connections, for example, between The Faerie Queene and Iron Man and between The Tempest and X-Men.

Just to give a flavor of the book’s analytical style, here is a classification the book gives for Arthurian legend in comic books.

  1. Traditional Tale. Arthur in comic book form with minimal superhero elements.
  2. Arthurian Toybox. Elements of Arthur sprinkled into other stories with no regard for literary context.
  3. Arthur as Translator. A modern superhero is dropped into Arthur’s Britain, like Mark Twain’s Connecticut Yankee.
  4. Arthur as Collaborator. Using Arthurian symbols and themes such as the sword in the stone or the round table.
  5. Arthur Transformed. Arthur placed into a new context.

Related post: Manga guides to science

Random number sequence overlap

Mike Croucher asked the following question on his blog. Suppose you draw M sequences of random numbers of length N from a random number generator. What is the probability that they will overlap?

Assumes your random number generator is a cyclical list of p unique integers. Each draw picks a random starting point in the cycle and chooses N consecutive values. We are particularly interested in the case M = 104, N = 109, and p = 219937 – 1 (the period of the Mersenne Twister).

We will simplify the problem by over-estimating the probability of overlap. The over-estimated probability will still be extremely small.

Assume all the draws are independent. This greatly increases the probability of repetition because now there is some chance that there are repetitions within each draw. That wasn’t possible before, provided N < p.

The probability of no repetitions in n = MN draws is

\prod_{i=0}^{n-1} \frac{p - i}{p} = \frac{p!}{p^{n}(p - n)!}

We can under-estimate this probability by replacing every term in the product with the smallest term. (By under-estimating the probability of no repetitions, we’re over-estimating the probability of at least one repetition.)

\prod_{i=0}^{n-1} \frac{p - i}{p} > \left(\frac{p - n + 1}{n}\right)^n = \left(1 - \frac{n-1}{p}\right)^n \approx 1 - \frac{n(n-1)}{p}

When n = MN = 1013 and p = 219937 – 1, the last expression above is approximately 1 – 1026/219937. That says the (over-estimated) probability of repetition is 1026/219937 or about 2×10-5976, thousands of orders of magnitude smaller than the chances of, say, drawing a royal flush.

Whenever you have such mind-bogglingly small probabilities, some probability outside your model has to be more important than the probability computed with the model. For example, we could question the assumption that the starting points are random and independent. Or we could question whether the random number generator was written correctly, or that the compiler correctly compiled the program, or that the operating system correctly ran the program, etc.

Related posts

Dart programming language design

Gilad Bracha’s presentation on Dart is interesting even if, like me, you do not intend to learn Dart. He has some good one-liners, especially digs at JavaScript, and some interesting ideas about programming language design. (JavaScript comes up frequently in presentation because of its popularity and because Dart compiles to JavaScript.)

Application programmers, unless they’ve committed serious crimes, should not be forced to deal with [ JavaScript etc.].

We’re not out to take JavaScript away. We’re not that stupid. I personally if I could I would, but Google probably wouldn’t.

There are millions of people writing JavaScript who do not understand JavaScript’s type model at all.

Some of the programming language ideas in the talk:

  • optional type systems
  • separating compile time type-checking from execution
  • delegating type inference to tools rather than the language
  • mirror-based reflection
  • which programmer mistakes should cause compiler errors and which should cause warnings

Gilad Bracha argues that type systems are important, but not for the reason most people give. Type systems are a form of documentation, and they help enable programming tool support, but their role in error detection is greatly overstated. Anders Hejlsberg, designer of C#, made a similar statement at the same conference.

See also Gilad Bracha’s comments during this panel discussion.

Related post: Dynamic typing and anti-lock brakes

Santa Claus was just the tip of the iceberg

From Skippy Dies:

Gradually the awful truth dawns on you that Santa Claus was just the tip of the iceberg—that your future will not be the rollercoaster ride you’d imagined, that the world occupied by your parents, the world of washing the dishes, going to the dentist, weekend trips to the DIY superstore to buy floor tiles, is actually largely what people mean when they speak of ‘life’.

Well said, though depressing. But it ends on a little brighter note.

Now, with every day that passes, another door seems to close, the one marked professional stuntman, or fight evil robot, until weeks go by and the doors … keep closing, you begin to hear the sound as a good thing, and start closing some yourself, even ones that didn’t necessarily need closing …

(Someone told me the book isn’t very good, but they thought I’d enjoy this passage, which I did.)

D programming language

Until last week I’d barely heard of the D programming language. Then I had a chance to meet Walter Bright who designed the language in 1999. I also met Andrei Alexandrescu who has been collaborating on the design of D since 2006. Both gave talks on D at Lang.NEXT.

Walter Bright’s talk was an overview of D. Andrei Alexandrescu’s talk was Three Unlikely Successful Features of D. Both were also part of the native languages panel discussion.

I haven’t written a line of D, but I was impressed with the ideas from D presented at the conference. I was also impressed by Walter Bright. When you spend three decades writing compilers, you learn a few things.

Not many developers use D, but the language has influenced more popular languages such as C++ and C#. For example, I believe the var keyword in C# and the auto keyword in C++ came from an analogous feature first implemented in D.

Related posts

C++ at Facebook

Andrei Alexandrescu said in a panel discussion last week that when he joined Facebook two years ago, maybe 90% of the programmers wrote PHP and 10% C++. Now there are roughly as many C++ programmers as PHP programmers.

One reason Facebook is shifting more work to C++ is to reduce operating costs such as power consumption per user.

Andrei’s remarks are about 24 minutes into this video. (link died)