What makes it worse for programmers is that our work is essentially creative in nature; progress is not defined by the number of bricks laid or the length of the ditch dug. It isn't possible to switch off your mind and just work at the task; you need to come to the compiler with your 'A' game.
On top of this, it really isn't possible to tell your clients that their projects are going to arrive N weeks behind schedule, because you're depressed. Well, it is possible, but not if you want to keep them.
One of the ways I deal with things, is to try and do maintenance tasks that generate 'little successes' throughout the day. So, even though my code isn't working the way I want it to, getting something else done tends to help get me back in the right frame of mind. Doing simple sysadmin tasks, or just spending half an hour tidying up my office a bit, or making dinner for a friend... it all helps out a lot.
Climbing has also been a big boon for me, because it's a very mental sport, can offer a string of 'easy successes' through bouldering, and provides some much-needed exercise and social interaction to the day.
But until I found ways to help myself deal with things, I could spend months off-line. Depression can be a very real problem, and for people who don't have good coping mechanisms, it is utterly crippling.