Godwin’s weak law

August 24, 2008 by Mastermind

The technology we use tells something about us. Considering myself a digital native, which internet-based communication technologies do I use? As for many-to-many communication I grew up with forums and still visit them a lot, but I was never into usenet really nor am I into social-networking platforms. In one-to-one communication I came to prefer instant messaging over Email, but I do not twitter or skype. In other words I adopted what was new when I started using the web and then never upgraded.

One reason for this is that I have become really familar with the specific dynamics of these communication media, which I think is essential to efficiently using them. When I use other unfamilar media, strage things happen. Once I entered a chat with the (auto-generated) nickname “kkk50″ thinking nothing of it and was instantly accused of being a racist. This seemed to be unmotivated aggression to me, until I realised, what “kkk” means in the states. In my culture it has no special meaning.

Learning the dynamics of a medium is learning the laws associated with it. Godwin’s law, one of the more prominent laws originating in usenet came to my mind, thinking of said incident:

As an online discussion grows longer, the probability of a comparison involving Nazis or Hitler approaches one.

I have seen this happen but not very often. Newer media needs new laws. I’d like to propose one here and inappropriately call it Godwin’s weak law for the beauty of the name:

As the number of members in an online community grows, the probability of someone advocating social Darwinism approaches one.

What is this about? While usenet is a broard network, forums are often narrow focused and restrictive on registration and posting. This lets forum users view themselves as members of a community. (Remark: You should really read Ernest Adams on this, it’s a classic). With the number of different members naturally the chances increase that communication fails. This problem is then adressed with the proposal, that only “fit” individuals should be granted access to said community. Sadly, more often than not, such ideas are not countered by rational arguments but by a “reductio ad hitlerum” which confirms Godwin’s law.

The fundamental flaw of the social Darwinism approach is that fitness in Darwin’s sense is the degree to which a population can adapt to an ecosystem it can not directly influence. Man has always influenced his ecosystem more than any animal race so it is questionable if the concept is even applicable to man. In any case it is inappropiate for artificial “ecosystems” like forums which can be influenced in many different ways.

The base type of int[] is object, not object[]

August 22, 2008 by Mastermind

I ran into a trap yesterday which I found undocumented or wrongly documented on the net, so I want to document it here myself.

In ADO.NET, consider the DataRowCollection.Find method:

public DataRow Find(
    Object key
)
public DataRow Find(
    Object[] keys
)

It finds a DataRow by its primary key. If the primary key is a complex key, composed by multiple columns you need to fill an array with all the key values that form the key sought-after. There are lots of things that can go wrong here, most populat according to my research being to get the order of the array elements wrong (that is not in the order specified as primary key) or confusing the method with the similar but not identical DataView.Find(), which does look for sort keys rather than primary keys.

Other than that things seem pretty simple. The following code looks straightforward but will get you an ArgumentException:

int[] key = int[2];
key[0] = 0;
key[1] = 1;
tableWithComplexIntKey.Rows.Find(key);

Yields:

Expecting 2 value(s) for the key being indexed, but received 1 value(s)

Now because of the heading of this post you will quickly spot the mistake but at first it looks as though we are passing two values. In case you haven’t realised it by now, int[] will be casted to object and the first signature of the method will be called. Instead of a complex key of two ints the array is interpreted as a simple key of int[].

This is not in the textbooks because in the toy-examples you’ll find things more like this:

tableWithComplexKey.Rows.Find(new object[]{0,1});

which does the trick in any case.

Further questions for language designers:

  1. If everything and especially any array is an object, why do arrays have a syntax different from any other object? Yes I know it’s only for convenience, but it is part of the problem here I think.
  2. Is it possible to retain (at least some of) the flexibility of ADO.NET, but convert such errors into compiler errors (I think of stronger typing here) which would make more sense than a runtime exception? If not in C#, is this possible in other languages? Which language features are needed to accomplish such goal?