mod_rewrite

mod_rewrite is cool.

As I mentioned in an earlier entry, I recently upgraded by blogging software to WordPress. WordPress uses mod_rewrite to support it’s pretty URL system. This works by defining a set rewrite rules base on regular expressions. For example, every time you call http://pezra.barelyenough.org/blog/2005/04/the-importance-of-a-rare-name/ apache internally rewrites the URL as /blog/index.php?year=2005&monthnum=04&name=the-importance-of-a-rare-name. This is not a redirect, the browser thinks it is pointed the pretty URL apache actually uses index.php instead. This behavior is nice, but it lead me to something even better.

I realized today that the perma-links generated by my previous blogging software were now 404s. mod_rewrite to the rescue, I just added a new rule so that the URLs blogger.com generated are now are rewritten to call WordPress instead. That means that if anyone linked to the existing posts, those links are not broken any more. And it only cost one line in a config file. Now, that is sweet.

The Importance of a Rare Name

My wife is pregnant with our second child, so I have been thinking about names quite a bit lately. We try really hard to come up with names that are usual. (Popular baby names is a good resource if you are engaged in this pursuit.) Our primary reason for this search is convenience — we would prefer that our child never be know as “blah W”. However, it recently occurred to me that there are additional benefits to having a rare name.

As a recent entrant into blogging I have, on occasion, engaged in a bit of ego surfing. For me, however, it is not particularly ego inflating. This is partly because Peter Williams is a fairly common name (and partly because I am not that smart). It is uncommon enough that I have never meet another one in person, but it is common enough that Google has no idea who I am. Google will probably never know who I am because there are quite a few other very interesting Peter Williams’ out there. When I look at my blog roll I see a lot of uncommon names. It seems that there might be a correlation between being an A-list blogger and having an uncommon name. In an age where most of our information is mediated by search engines, an unusual name seems to be a valuable asset.

I fear that whatever name we chose for our children it will not be rare enough. Williams is just too common. I wonder if this might lead to a cultural shift in which children given all their names, rather than inheriting a family name. If the benefits of an unusual name included demonstrable social and economic benefits I think many parents would be quick to dump the family name. On the other hand, it could be that the emotional attachment people have to their family name is too great for it to be easily discarded. And at this point it is not clear, to me at least, that an unusual name actually has significant economic benefit. I think it is too early to tell if this shift will happen — I think it might take a generation or more such a fundamental change to take place — but if it did it would be an terribly intriguing.

For what is worth, I can say that my wife and I have no intention of giving our children a last names other than Williams.

WordPress

I have bitten the bullet and changed blogging systems, again. I really wanted categories and trackbacks, which Blogger does not support, and easier comment moderation since I am already seeing a bit of comment spam. So far I really like WordPress.

Sorry for any inconvenience and let me know if you see any problems.

The Perils of Duck Typing?

In The Perils of Duck Typing Cedric writes about some fears he has related to duck typing.

He says

Duck Typing is a big time saver when you write code, but is it worth it? Don’t you pay this ease of development much later in the development cycle? Isn’t there a risk that you might be shipping code that is broken?

The answer is obviously yes.

The proponents of Duck Typing are usually quick to point out that it should never happen if you write your tests correctly. This is a fair point, but we all know how hard it is to guarantee that your tests cover 100% of the functional aspects of your application.

There is certainly a risk that you will ship broken code. In fact, you will almost certainly ship broken code. But you will ship broken code regardless of typing model you use. Static typing is no solution to the problems of defects. But the fact that you saved a lot of time by using duck typing in development means that a) you can send a little more time on testing and there by reduce number of defects you ship, b) get to market earlier or c) both. The fact of the matter is that type related error do not happen often enough in practice to make them worth worrying about (when is the last time you got a ClassCastException while working Java collections).

Cedric goes on to describe the use of interfaces as documentation (using interfaces to document what methods must exist for a piece of code to work) while implying that duck typing prevents this. Interfaces as documentation is a nice use of interfaces but duck typing does not preclude this. Smalltalk has SmallInterfaces. In Ruby, MixIns are commonly use to define the set of methods that are required. But both of the environments are duck typed. In Ruby, for example, if I create a MixIn to define an interface, you can “implement” my interface merely by implementing the appropriate methods, regardless of whether you include my MixIn or not. Interfaces as documentation should be treated just like all other documentation — when it is helpful use it, when it is not ignore it.

To be fair, Cedric likes Ruby because you can used MixIns to define interfaces, but I think his has conflated two completely separate issues. Duck typing does not preclude well documented interfaces. You can poorly design and document an interface a statically typed language just as easily as you can in a duck typed one. You should take care to reasonably document the interfaces you use, regardless of the type system.

I’m a Completionist Organic Piratic Elf, How About You

I have noticed a lot of way to categorize people lately. There is Clay Shirky’s One World, Two Maps where he talks about the differences between incrementalists and completionists. (Those names are from this essay that covers the same thing Incrementalists and Completionists[via].) Shirky’s essay pointed to From Pirate Dwarves To Ninja Elves which provides another couple of dimensions on which to classify people. Finally, there is Organics and Mechanics[via].

There is value in simply naming a concept — if you doubt it, just look at all the buzz around Ajax since it got a name. I think this is because it lowers the bandwidth needed to track the concept. Having these names makes classifying the people I know a lot easier. For me, that turns out to be fairly helpful because it allows me to more easily tailor my interactions with them. Even if you do not find it helpful it is still an interesting set of articles to read because it gives you a little insight into how others might be categorizing you.