June 16, 2007 — jao

I’ve just seen David Weinberger’s recent Authors@Google talk, a deeply interesting overview of his new book, Everything is Miscellaneous. At first sight, Weinberger’s talk has little to do with programming. He discusses our efforts to classify objects in the world, starting with Aristotelian categories, where there was one and only place for every thing (and, presumably, one thing for every place)–a line of thought rooted on our direct experience with physical objects, culminated with Dewey’s decimal classification system. A line of thought that our modern, digital world has made obsolete. Weinberger is an excellent communicator and makes his points with a fine sense of humour, so, if you have fifty minutes to spare, you can do far worse than pressing the play button below before go on reading why am i mentioning this video in programming musings:

Still with me? Well, the fact is that hearing Weinberger’s thoughts i’ve been remembered of a little exercise i was doing this morning, as part of my recent efforts to finally come to grips with Haskell. You know what? Static typing feels a lot like Aristotelian categorisation: one and only one type for each variable. As is the case with Aristotelian categorisation, there are many situations where a rigid type system works well: we use categories all the time, and they obviously capture part of the structure of the world out there. But they inevitably break down at some point. In my little Haskell exercise (an interpreter for propositional logic), there was a point where it would have been extremely convenient to have more than one type for some of the variables i were using. Maybe it’s just than i’m used to working that way in dynamically typed languages, where the types of the parameters of my functions are in constant flow, and i cherish the ability to widen their domain on the fly.

As mentioned in the talk, Aristotle would be horrified at the prospect of having anything in more than one place of the tree: that would be chaos!. But in our digital world, tagging and mash-ups are arguably revealing themselves as more apt ways to organise our knowledge of the world. There are myriad faces to everything, and allowing different points of view is not only natural, but seemingly useful.

In the same (or, at least, analogous) way, static typing abhors (actually prohibits) variables with mutating types. One has union or algebraic types, that’s true, but one has also the feeling that using too heterogeneous types to construct them is going a bit afield. Could that be as misguided as Aristotelian categories? I don’t know. Building software is so complex that maybe we need the safety net of rigid categorisations. But i’ve noticed repeatedly while programming in, say, Lisp, that using dynamic typing makes things easier in many contexts. The nagging feeling of insecurity i had when i started using Scheme about the lack of type declarations has progressively disappeared, up to the point that languages as beautiful as Haskell can sometimes feel like a straitjacket.

I might be misguided, and perhaps my sense of security is bogus because it derives from very small projects (i have never participated in a large project using a dynamic language), and that liberally bending the type system really leads to chaos in the long run. Maybe the right way to realise this many-facets approach to modeling the world is to put type classes and parametric polymorphism to good use–although even there, i find CLOS generics more natural. But one wonders, could it be that, like our data, the real world problems out there are too complex, too multifarious to fit in a static ontology?

Come to think of it, i’m realising than i’m just badly restating the line of thought people like Alan Kay or Gerry Sussman have been defending for years. Specially their seeking inspiration in biological systems (those complex, messy things so marvelously organised) to model our computing and programming systems. I think that what i’m trying to express (and much, much more) is finely put, for instance, by Alan Kay in his famous talk The Computer Revolution hasn’t happen yet (if you haven’t seen it, please click that play button below) or, more recently by Sussman and Hanson in their paper Building Robust Systems. As i mentioned, in both cases, convincing parallelisms with biological systems are put on the table, and a dynamic outlook to programming systems (including generic functions and MOPs) are favoured. My gut feeling is that these ideas are to programming what Weinberger’s are to data management. I hope that reading and hearing Weinberger, Kay, Sussman and Hanson will convey this feeling better than these somewhat iffy ramblings.

All that said, i still get a kick out of learning Haskell. It must be the Aristotelian in me! :-)

Update: Some interesting comments over at reddit.com point out how my analogies could be (and probably are) flawed. In particular, there’s a reference to what looks like a very entertaining book: Practical Foundations of Programming Languages (PDF), which argues exactly the opposite:

This is a working draft of a book on the foundations of programming languages. The central organizing principle of the book is that programming language features may be seen as manifestations of an underlying type structure that governs its syntax and semantics. The emphasis, therefore, is on the concept of type, which codifies and organizes the computational universe in much the same way that the concept of set may be seen as an organizing principle for the mathematical universe. The purpose of this book is to explain this remark.

Also, check the comments here in WP: they’re quite interesting too!