Archive for October, 2004

Diagnostic Typing

Thursday, October 21st, 2004

One of the dialectics in computer science is between dynamic and static typing. Dialectics are like professional wrestling. Cheap fun. But, they leads to category blindness. So let me blather a bit about a “third way” that I call diagnostic typing.

At one point in my career I spent a few years deeply committed to the static typing camp. The height of that experience was an amazing day when we successfully linked, for the first time, a huge complex program. It consisted of hundreds of thousands of parts written by numerous authors and code generators. It worked! First time! Getting to that point had required tremendous labor, since the static type checking demanded by the language we were using had forced us to fix lots of stuff that might have been left for latter. At that moment it seemed worth while that we had deferred so much immediate gratification for so long.

Late in the project we had some really amazing bugs. Bugs that took weeks and teams to fix. Fun bugs with long interesting stories to tell about each of them.

During that later period I found my self writing what I came to call diagnostic typing code. This code would work to prove a complex declaration about the nature of a data structure. These declarations were put forward by the team members. For example somebody might say “All the records of type A are in the dictionary D.” and then somebody else would say “Ah, I thought the core set of those aren’t in the dictionary.” At that point I’d go off and write some code to to check if these declarations were true. It was fun because the truth was almost always much more complex than anybody thought. The bugs were all around the edges of these.

So the dialectic between dynamic and static typing is actually a kind of layered thing; with at least with three layers. Static, Dynamic, and Diagnostic. Static type checking is done at compile time. Dynamic type checking and dispatching is done at runtime. Diagnostic type checking is done intermittently; usually in response to a demand or a fear. It was extremely valuable to become explicit about some of the declarations that had been implicit.

Diagnostic type checking can be very very expensive. That makes it a lot of fun! It lets you can write all kinds of assertions about your program that would never be practical to check or enforce at the compile or runtime. You can get out the big guns: graph theory, statistics, coverage, grammars, budgets, spelling correctors. For example: all the window components form a strongly connected component via their child/parent arcs. For example: the elements of this hash table are uniformly distributed. (As an aside I don’t think I have every found a hash table that was well behaved in the wild.)

One of my favorite examples. This isn’t just for data structures you can do this on program traces too. Back in the 1970s somebody at CMU wrote a paper about using the ideas from language grammars to declare the patterns over calls on class instances. Things like: x:foo<-create(x); {open(x); {update(x)}+; close(x)}+; destroy(x)}*. In a later life I would sometimes write code to diagnostically check statements like that by using the tracing facilities in Common Lisp.

I wrote a lot of this diagnostic typing code for the persistent store using prolog. I would dump the entire persistent store into a suite of prolog assertions and then write the diagnostic typing declaration as small prolog programs who’s execution would prove or disprove these declarations. While that found a lot of very very subtle bugs I found it more fascinating how it raised raised the level of discussion about the work.

This kind of approach will, I suspect, become more common real soon now. So much of the data sloshing around on the net is full of surprises that diagnostic typing declarations would reveal. Moving the data across organizational boundaries creates a demand for tools that can frame the discussion between the parties.

One of the reasons I’m suffering a fit of enthusiasm for RDF is how it appears to offer a normal form, much as prolog assertions did for me in my previous experience, for just this kind of problem solving.

This trio: static/dynamic/diagnostic typing are all about shifting around the work, the trust, and the gratification. Don’t overlook the gratification. There is a lot of fun to be had in diagnostic typing approaches. I doubt you can write down all the declarations about the data before it starts flowing. Why defer the fun of flow?

Tree of Life

Sunday, October 17th, 2004

Evolutionary tree of life
The drawing above shows three thousand species arranged around the perimeter. The arcs in the interior are the result of pattern matching on the rRNA of those species, and show an estimate of what evolved from what. So at about 5Pm on the clock we have the Archaea which were discovered only recently hot springs, and other exceptionally hostile environments. Running counter clockwise from there we have the Bacteria, the Protoists, the Plants. At 12 pm we have an assortment of things between plants and animals. Then the Animals (including a mark reading ‘You are here” for we homo spaiens). Finally the Fungi. You can down load this chart as a PDF off this page. It really makes your PDF viewer work hard!

Comic Genius

Sunday, October 17th, 2004

Benziono NapaloniI think I’ll try out the Brad DeLong technique and bring your attention to something by quoting the entire article. Let’s see if I get this right.

In the royal court of the shrill the Third Assistant to the Second Vice Jester innovates new modalities of shrill giggling.

It’s debatable

Now, I had never seen George Bush speak for any length of time before watching the three presidential debates.

I had no idea.

The man is a comic genius.

The sheer breadth of his repertoire, the winks, the allusions, the outright mimics of so many comedy greats, it’s astounding, exhilarating, it’s…

Oh, where to begin?

It’s the ongoing homage to the old Mack Sennett zanies: Too Many Highballs, The loud mouth, The bluffer, A close shave, Hubby’s latest alibi, Daddy boy, The beloved bozo, Remember when? …the list just goes on and on.

He’s nailed, I mean nail-ed, the Emmett Kelly frown, Harry Langdon’s blank stare, Sam Kinison’s delivery, Judy Holliday’s incredulity, Jack Benny’s shrug, Harold Lloyd’s eye shifts, Jack Oakie’s Benzino Napaloni pout, Don Knott’s indignation, Bill and Ted’s memory lapses, Shirley Temple’s lemon-squeezed determination, Lucy’s look when caught by Desi and that thing, that thing he does when he gets all riled up by something Kerry said and, when given the chance to respond, just freezes.

Man, that’s good television.

As a leitmotif, I sensed a grand homage to Gilda Radner’s Miss Emily Litella character in all those instances where he was asked a question, and responded with a fully off-topic descent into nonsense.

Actually, Mitch McConnell had a minimum wage plan that I supported that would have increased the minimum wage. But let me talk about what’s really important for the worker you’re referring to…

And, let’s be frank, who but the most avant-garde comedian would maintain a lump of white spittle on the right-hand corner of their mouth for the entire first half of a “serious debate” if they had no ulterior vision in mind?

(A coincidence that Derrida had just died, and a new era of perception had dawned? I think not. The man knows his audience.)

Gosh, there are so many to choose from, but I really think the defining moment came in the second debate, when discussing the issue of Supreme Court appointments:

That’s not what the Constitution says. The Constitution of the United States says we’re all—you know, it doesn’t say that. It doesn’t speak to the equality of America.

That, my friends, is comedy gold.

Is he wired?

Well, let me just ask you this: would you expect Letterman or Leno to perform their monologues without cue cards?

Let’s be honest, now.

Standardizing Social Networks

Friday, October 15th, 2004

Standard bar code for a relationshipIf I had a EAN.UCC Company Prefix of my very own (only $750 dollars!) then I could assign all my relationship partners a unique GSRN or Global Service Relationship Number (pdf). This would be very useful when I need to quickly retrieve the details of any given relationship. In some cases I might want to hand out multiple GSRN to the same person, since our relationship is framed in different modalities; friend/coworker, wife/mother/helpmate. I could then mark up all my correspondence so it might be quickly associated with other aspects of the relationship. Membership cards! Better yet jewelry with RFID chips embedded. Then when they drop by the house I could dynamically customize their visit to my home.

Bar codes? Not just for tangible items anymore! Label the intangible. This is going to be big!

Collaboration is better even than nice!

Thursday, October 14th, 2004

These results are just delightful! Twenty years ago people started running a tournaments to find the best algorithm for playing a repeated prisoner dilemma game of random length. Pretty quickly the winning strategy (nice is better than mean) emerged and nothing much has changed since them.

This year one of the entrants found a new approach!

Instead of entering one algorithm they entered 60. In the metaphor of they game they didn’t send one criminal to be repeatedly arrested; they sent a gang. Members of this mafia were very loyal to each other and they methodically ganged up on the other players and the police. When matched with an opponent in the game these gang members would try to puzzle out if they were playing against one of their own or not. In the real world you identify others of your kind with various signalling devices: secret handshakes, gang tags, etc.

In this game they can only signal to each other via the game. Using patterns in their game play mafia members recognize each other. At that point they can game the police in ways that to raises the gang’s overall score.

It’s just wonderful. This is the classic model of all game theory! And even in this tiny little dishpan model collaborative groups form and once they form they out compete the players that fail to collaborate. As Dave Weinberger once pointed out, we are a species that will form communities even if it means tapping out the alphabet on the wall of our cell.