Monday, September 28, 2009

Haskell IRC

The Haskell IRC channel is great.  For those of you who don't know, IRC is an old school chat room.  The Haskell instance has dozens of knowledgeable people on at any time of day.   They are generous with beginners like me.  I've asked a few dozen questions by now, and always got an answer within a minute or two.  If you're learning Haskell, I highly recommend it.

orangutan and hound

http://www.huffingtonpost.com/2009/09/26/orangutan-and-hound-dog-b_n_299010.html

Sunday, September 27, 2009

Yuri

I was at Microsoft Research in Redmond this week.  I met a Russian logician named Yuri Gurevich who told me a funny story about a math class when he was a child:


I remember, in a geometry class, my teacher wanted to prove the congruence of two triangles. Let’s take a third triangle, she said, and I asked where do triangles come from. I worried that there may be no more triangles there. Those were hard times in Russia, and we were accustomed to shortages.
He was afraid they might have run out of triangles!

Good article on Met director

http://www.nytimes.com/2009/09/27/arts/music/27mcgr.html

Saturday, September 26, 2009

Alicia de Larrocha's NY Times obituary.

Design Patterns

I've been using Haskell a lot lately.  I wanted a deeper understanding of the interaction of type classes, since the number of type variables in mine is exploding as I try to simulate the ML module system in type classes.  Obviously I'm doing something wrong.  Thus, I've been reading the standard papers on functional dependencies, etc.  For variety, I figured I'd reread some object oriented programming stuff, since they've thought a lot about class relationships.  (Though type classes bear little resemblance to OO classes, there are some similarities.)  So I picked up the Gamma et. al Design Patterns book.  I know I live in a functional programming bubble, but I'm surprised at some of the stuff I'm reading.

  p.22.  On "parameterized types" aka. parametric polymorphism, aka. generics.
  "None of the patterns in this book concerns parameterized types, though we use them on occasion to customize a pattern's C++ implementation.  Parameterized types aren't needed at all in a language like Smalltalk that doesn't have compile-time type checking."
It sounds as if the authors think of compile-time type checking as a scourge on programmers that
forces them to use parameterized types.  
  To be fair, they do say that parametric types are another way (the other two being class inheritance and object composition) to structure your programs, each having strengths and weaknesses.  Interestingly, they point out that you can't change the implementation of a polymorphic function at run time.  That's true (I think) but I'm struggling to understand what they mean.  For instance, you might have two implementations of sorting with different behaviors (e.g. one better on one kind of data, the other on another kind), and you might notice that a chosen sort of an input stream is performing badly and want to switch to the other algorithm.  This is an easy thing to do in ML or Haskell, as I suppose it is in C++.
Thus, I don't know what they mean by saying you can't change the implementation at runtime.  Do they mean, the implementation of a single function?  If so, I have no idea why you would want to do that.  How could you reason about your function f if sometimes it's calling f1 and other times it calls f2?
   The abstractions of design patterns seem interesting, but I'm not seeing yet how to apply the ideas to functional programming.

Sunday, September 06, 2009

Babysitting coop

Fascinating story from Paul Krugman:
I like to explain the essence of Keynesian economics with a true story that also serves as a parable, a small-scale version of the messes that can afflict entire economies. Consider the travails of the Capitol Hill Baby-Sitting Co-op.
This co-op, whose problems were recounted in a 1977 article in The Journal of Money, Credit and Banking, was an association of about 150 young couples who agreed to help one another by baby-sitting for one another’s children when parents wanted a night out. To ensure that every couple did its fair share of baby-sitting, the co-op introduced a form of scrip: coupons made out of heavy pieces of paper, each entitling the bearer to one half-hour of sitting time. Initially, members received 20 coupons on joining and were required to return the same amount on departing the group.
Unfortunately, it turned out that the co-op’s members, on average, wanted to hold a reserve of more than 20 coupons, perhaps, in case they should want to go out several times in a row. As a result, relatively few people wanted to spend their scrip and go out, while many wanted to baby-sit so they could add to their hoard. But since baby-sitting opportunities arise only when someone goes out for the night, this meant that baby-sitting jobs were hard to find, which made members of the co-op even more reluctant to go out, making baby-sitting jobs even scarcer. . . .
In short, the co-op fell into a recession.