Saturday, November 22, 2008

Biblical laws

During the last few years I have slowly come to a conclusion: the reason for a lot of Biblical laws is not actually religious (as in, God has decided that something should not be done and that's that); it is the fact that non-religious commandments would have required explanations beyond the Jews' knowledge at the time or at least that they would have not obeyed them for long otherwise.

Take incest, since it does make for a rather glaring weirdness. Most people - an overwhelming number - consider incest to be "yuck"... the term cannot be discussed in polite company, only among porn freaks. When people ask "who did Adam and Eve's sons marry?" and receive the obvious answer "their sisters", they go "that's disgusting".

And yet... incest was not forbidden for a long time in the Bible. A quick search on Google reveals this page where we can see that Abraham married his half-sister, Moses' father married his aunt, and even when incest started to be prohibited it started with father-child relationships and only later were siblings added.

Why is this? Well, why are incestuous relationships prohibited today, even for non-religious people? As it happens sometimes, the state actually has some sort of justification here: people seldom pay attention to reproduction until it's too late and children between close relatives will have a much higher probability of genetic defects. So, since prohibiting only the "having children" part is difficult and would require genetic testing for each birth - and then, what do you do with an "illegal" baby? - the state found it much easier to prohibit the sexual relationship altogether.

Now. Genetic defects. What exactly would be the way to explain that to a tribe of Jews five thousand years ago? How can you tell them "if you do this, in the long run (generations) your tribe will die out"? Well, making it a religious commandment would be one way :)

If that is the case, why wait a few thousand years? Why not start prohibit this right away? Well, the reason is very likely the catastrophic diminishing of the gene pool at the Flood. Prior to that we have no way of knowing how good the genetic material was, but we can safely bet that the eight saved people on Noah's boat were not the most perfect specimens - and even if they were, it would still be too small a population. Which meant that genetic defects would very soon start to propagate... and what do you know, the average age starts falling rapidly after the Flood, from around a thousand years to around a hundred. (Incidentally, this means that living to a thousand years is a viable possibility for humans, we just have to discover what got lost.) Therefore, the most likely conclusion is that the prohibition was not needed before - there were few enough defects that the chance of two parents having the same recessive one (thus increasing the chance of it being dominant in a child) was too small to matter.

What about another example: basic hygiene. Read Leviticus 15 and get stunned by the detailed instructions. Would a plain "wash yourselves so you don't get sick" have worked? In fact, there's even a mention of the reason for this commandment: "You must keep the Israelites separate from things that make them unclean, so they will not die in their uncleanness". How could you persuade a bunch of stubborn tribesmen to obey it? Why, make it religious: "... for defiling my dwelling place, which is among them".

What about having a day of the week off? Well... in 1922 Ford reduced the workweek to 48 hours (see Wikipedia) so it was even longer before then. That's in the richest country in the world. Can you imagine any employer granting an employee a non-working day a thousand years ago, let alone five thousand, unless it was a religious commandment?

Ok... wrapping it up. It seems that whoever wrote (or at least directed the writing of) the Bible had a lot of knowledge for the time. Prophecies can be claimed to have been added after the fact; how do you add genetics and hygiene and worker rights in a thousand-years old book?

Thursday, November 20, 2008

More on incentives

While watching a concert I started thinking about the amazing cooperation needed for such a task - there are dozens of people on stage, playing various instruments in very specific ways, and hundreds of people in the audience, whose only responsibility for a successful concert is to stay quiet during performances and maybe applaud in between. The performers are rewarded financially if they perform well, and they risk being fired if they don't. The audience risks being fined or even jailed if they don't behave.

Given all that distinction - disassociation on one hand, jail on the other - who do you expect to cause more intentional trouble on the average? My money is on the audience, of course [grin].

Market incentives work a lot better than force incentives. To me, this is a beautiful example of capitalism versus socialism. Even though the risks of disobeying the state are much greater than the risks of disobeying an employer or a business associate (there's no meaningful distinction between employer and customer), cooperation is still more likely to be encountered in the market.

Socialism does not scale

I was deleting some spam and reflecting on the whole issue... as I was telling someone a few weeks ago, the problem with spam will be stopped when it will become a serious issue. Right now, the problem is distributed: a few benefit and a lot have to pay for it. (Just like in politics [grin].) Worse, there is a socialism of sorts in the relationship between internet providers: the sender doesn't have to pay the carriers for the traffic it sends through them. This messes up the incentives completely.

A simple scheme like a hundredth of a cent per email would make it too expensive to send bulk emails ($100 per million emails) while not affecting regular users in any way; legitimate companies would have already a large enough internet subscription that any email charge would be drowned in the noise; finally, large, voluntary mailing lists like RISKS would need something on the order of maybe a few dollars a day - again, irrelevant when compared with the price for the actual equipment and internet service fee.

Furthermore, this scheme would create the proper incentives - the ISPs would penalize other ISPs who allow spam through them, the PC owners who don't secure them and let their PCs become spambots would suddenly have a financial interest to fix the problem, which would in turn put pressure on the OS makers (well, on Microsoft [grin]) to improve their software and so on.

Socialism works in small settings, like the family or small comunities, which is probably why it seems so natural to people. Free markets are much better at solving large-scale situations though. They can be thought of as real-life optimization machines - neural networks made of people, if you will.

Saturday, November 08, 2008

Extracting named variables from an array

My code uses the following pattern in a lot of places:

  1. string[] array = GetSomeData();  
  2. Debug.Assert(array.Length() >= 3);  
  3. m_Member = array[0];  
  4. m_Password = array[1];  
  5. m_SomeOtherInfo = array[2];  


... and so on. This is happening often enough that I tried finding a clearer way of expressing it. I even asked a question on stackoverflow. The answers I got aren't bad, but I came up last night with a solution I like more. (It doesn't mean it's the best, and it does look a little kludgy, but I like the way my code looks.)

  1. using System.Diagnostics;  
  2.   
  3. public static class ArrayExtractor  
  4. {  
  5.   public static void Extract<T1>(this object[] array, out T1 value1)  
  6.       where T1 : class  
  7.   {  
  8.     Debug.Assert(array.Length >= 1);  
  9.     value1 = array[0] as T1;  
  10.   }  
  11.   
  12.   public static void Extract<T1, T2>(this object[] array, out T1 value1, out T2 value2)  
  13.       where T1 : class  
  14.       where T2 : class  
  15.   {  
  16.     Debug.Assert(array.Length >= 2);  
  17.     value1 = array[0] as T1;  
  18.     value2 = array[1] as T2;  
  19.   }  
  20. }  


This only shows the code for 2 values, I'm going to write it for up to 10 values or so. It's not as elegant as the other solutions but now I can simply write

  1. string fileName;  
  2. string contents;  
  3. ArrayExtractor.Extract(array, out fileName, out contents);  


or even better

  1. array.Extract(out fileName, out contents);