Thursday, November 22, 2012

Regret

I was listening to this this podcast last night about the psychological effects the Milgram experiments had had on the participants. I have to admit that it had never occurred to me how those people must have felt being equated with Nazi concentration camp guards.

The subjects who had been tricked as part of the experiment into participating in (mock) torture seem to have been dismissed as bad people and sent off to think about it for the rest of their lives. Thinking about it a little further leads me to conclude that the experiments were not only cruel, they were basically pointless because they'd already been done.

Unless we were to resort to the idea that Germany had been overtaken by an unexplained wave of psychopathy during WWII then we'd have to conclude that ordinary people can be made to do terrible things under certain circumstances. Unfortunately, Nazi Germany is far from the only example of this.

I've never been subjected to that kind of experiment but I have been plagued with regret. I have on many occasions in the past caused pain for others or myself through stupidity or fear and part of my mind won't stop reminding me of that. I suspect that regret is a bigger problem than commonly acknowledged. It is the worst part of depression for me because past actions can't be changed.

The first thing to notice about regret though (particularly for acting badly toward others) is that it's a sure sign that you're not a sociopath. Your conscience is working just fine, in fact maybe a little too well. Relief at this thought seems paradoxical though. If you feel bad, you shouldn't but if you don't then you should.

But regret, beyond what is useful for us to learn from and regulate our behaviour, that debilitating regret, is also based on a false premise. That premise is free will. Only if you could have done otherwise but chose to do the wrong thing do you deserve to suffer. Surely if you had no choice, you are blameless. You may need to be corrected so that you do better next time but that's it. There's no need to go on punishing yourself.

Fortunately, with a little thought, you can demonstrate to yourself that this is in fact the case. You had absolutely no choice but to do what you did. Don't believe me? Lets do a little time travel.

Lets go back in time to when you made the biggest mistake of your life (so far :P ). We'll put nature into reverse, return every atom in the universe to the point that it was at, at that moment. Of course, every atom in the universe includes the ones that make up your brain. So there you are with exactly the same set of inputs, the same state of mind. What will you do? You'll do exactly as you did before. By what mechanism could you do otherwise?

If I haven't convinced you, I'd recommend Sam Harris's excellent book "Free Will". In it, he gives free will the sound thrashing it deserves and also explains why even the idea of a soul (if you believe in that sort of thing) can't rescue the concept of free will.

So where does that leave regret? I'd define regret as anger at one's self. And what are you angry for? For doing what you absolutely had to do?

This isn't a license for bad behaviour. Of course we have to constrain our actions. But regret, as with anger toward others, is only justifiable to the extent that it improves us.

So the next time, you're chewing yourself out over past actions, consider whether that's really necessary or if you've already learned. Over time, maybe you'll find that the regret dissipates and you're able to focus on your present actions.

Thursday, March 15, 2012

Activerecord Boolean False Gotcha

Unless you've got a good reason not to, when you declare a boolean field in Rails/ActiveRecord, always set give it a default and disallow null. Eg:

 t.boolean "troublemaker", :default=> false, :null => false

The reason for this is that when you want to search on it later to see if it's false, you can simply say:

Student.where( :troublemaker => false)

The above statement won't find students where the :troublemaker is null so it's a good thing you didn't allow that to happen.

If you already have boolean fields in your DB that may have null values which you were regarding as false, it's easily fixed. Just run a migration like:


class DefaultTroublemakerToFalseForStudents < ActiveRecord::Migration

  def self.up
    change_column_default :students, :troublemaker, false
    Student.where(:troublemaker => nil).each {|s| s.completed = false; s.save!}
  end

  def self.down
    change_column_default :students, :troublemaker, nil
  end

end