This may seem weird, but I think that programming can actually contribute to depression. I had a minor episode the other day and it was quite surprising to me. I think one reason for that is that being social is a large element of being happy. I think the best programmers are those who are so internally happy without external stimulation, that they can continue to hone their craft and not fall into the pit of depression. I also think that programming attracts people who are depressed and don't want to do the hard things that they know they have to do in life. Just take a minute or a day and sit in silence with yourself and you will know what is important in your life. Do that.
Interesting post, but I don't agree with the last two sentences. After many hours and many days of silence with myself didn't help at all, it made things worse for me. For me, the start of "healing" was not to pay attention to my random thoughts, not to try to think things over, not to think about my life, etc.
But the main problem with this whole thing here, these threads about depression, and the "advices", that we are not the same. What works for me, won't work for others. I have OCD, so having random thoughts all the time is an essential thing to my problem. Others have other bases.
So fighting with depression should start with looking for an expert.