Monday, June 21, 2010

Harper and Crary for America

I was unaware of this great PL T-shirt. I want one, but it was apparently a limited edition.

Monday, June 14, 2010

Awesome visualization

Tallest mountain to deepest ocean trench.

Beautiful quote

"What I cannot create, I do not understand."  - Richard Feynman

Probably my favorite aspects of programming is that it (usually) forces you to understand what you are doing.  There is something special about the feeling you get when you understand an idea so completely you can teach it to a computer.  The first time I can remember feeling this was when I wrote a toy implementation of the simplex algorithm for linear programming.  The first time I read the description I found it really hard to follow.  Only after writing down the types of the operations, and slowly decoding the natural language into code did I feel like I really understood what was going on.  Then it seemed like such a simple idea I was amazed I initially found it so difficult.

Note that the contrapositive is "What I understand, I can create."  Unfortunately, this does not rule out creating without understanding.  I occasionally take algorithms out of books without understanding them completely.  While they usually work as expected, I forget how the program works almost immediately, and learn next to nothing from the experience.  It is only through debugging that I gain any understanding of how the program works.  Needless to say, this is an incredibly inefficient way to learn.

Thursday, June 10, 2010

More Polymorphic Recursion

I've been obsessed with polymorphic recursion lately.  I originally just wanted to write a data structure like a list but with efficient insertion on both sides, sometimes called a deque.  The problem is that type inference in the presence of polymorphic recursion is undecidable, in a nice reduction to semi-unification by Herblein.  On the other hand, we don't need type inference.  I'm more than happy to write the type of a function in ML or Haskell, and type checking is decidable with polymorphic recursion. It's sad that SML will never be able to do this.  Apparently OCaml 3.12 will allow it. 

Reading the mailing lists from 1994 when this was being debated on the Haskell mailing list, I found a very interesting example from Mark Jones.  He found that polymorphic recursion would break his implementation of type classes that didn't pass a dictionary at run time.  Without PR, he could statically analyze the whole program and hard code the type class function calls.  He points out with the following that it's no longer possible with PR:

f  :: Eq a => a -> Bool
f x = x==x || f [x]
Note that if I write
data D = D
instance Show D where
_ == _ = False
then calling f D will require infinitely many instances of f. 
 
I also found a good paper by Kfoury et al. showing lots of examples of polymorphic 
recursion in action, and how many of the cases can be overcome using intersection
types (my friend William Lovas' specialty.)

Tuesday, June 08, 2010

The Club

Interesting.  The Club anti-theft device for cars is either bad for society, or your car, depending on the skill of the car thieves.

Sunday, June 06, 2010

Mozart and microbes

Is this for real?

A German company is playing Mozart over speakers to its microbes because it makes them eat sewage faster.

Buying and renting

I've been looking for apartments in New York City recently.  The rents are high.  This is partly due to rent control, but the prices are not very much higher than the Bay Area where I grew up.  Apparently the real estate in NYC is so expensive, even relative to the high rents, that it usually doesn't make sense to buy an apartment.  The New York Times has a handy buy/rent calculator where you can put in the price of the house, cost of rent, cost of mortgage, etc. and it will tell you how long you'd have to own a house before it paid off.  Most of the numbers I tried for the Manhattan apartments I've been curious about never pay off, i.e. it's always better to rent.    Out of curiousity, I was looking around the internet for similar prices in the Bay Area.  Since the interest rates are low now, I thought naturally it would be a better time to buy than when the rates are high.  I was surprised to find the following analysis of my mistake:

It is far better to pay a low price with a high interest rate than a high price with a low interest rate, even if the mortgage payment is the same either way.
  • Your property taxes will be lower with a low purchase price.
  • A low price gives you the ability to pay it all off instead of being a debt-slave for the rest of your life.
  • As interest rates fall from high to low, house prices increase.
  • Paying a high price now may trap you "under water", meaning you'll have a mortgage larger than the value of the house. Then you will not be able to refinance because there you'll have no equity, and will not be able to sell without a loss. Even if you get a long-term fixed rate mortgage, when rates inevitably go up the value of your property will go down. Paying a low price minimizes your damage.
 The prices are presumably lower when the interest rates are high because the demand for housing at a fixed price falls.  I'd like to see if there is really parity in the price of a mortgage for the same house at different times with different interest rates.  Does anyone know a study like this?  I'd be really surprised if the actual mortgage payments were the same.  I suppose you could use Case/Schiller and the historical interest rates to calculate the inflation-adjusted mortgage payments, but I don't have time to do it myself. 

Atul Gawande

I was at a party last night, speaking with a last year anesthesiology resident from the Boston area.  I told her I was reading Atul Gawande's excellent book 'Better'.  She said, "Oh, I know Gawande".  I found this unsurprising, as he is not only a surgeon but a quasi-celebrity with many articles appearing in popular places like the New Yorker.    She continued,  "I was the anesthesiologist on his team in a couple of surgeries recently."