Well, there's no magic bullet. You could ask you professionals about getting cognitive therapy or look up a psychoanalyst in your area.

'Talk thereapy' like psychoanalysis has been severely out of fashion in recent years because it's intuitive rather than rigorous, so your existing professionals might not want to recommend anyone. Where it does well is in helping the patient to get fully familiar with the course of his or her depression - not so much to identify a single cause, which there may not be, as to help identify the differences between the malady and the ordinary ups and downs of life. If you're a very verbal, analytical person, this might be helpful for you. I sometimes feel a bit frustrated when I see a psychiatrist that he just catalogs a few details about my mood, sleep patterns etc. and we don't talk much about the experience of things - a bit like a doctor that writes you a prescription for a painkiller but doesn't seem to have any interest in the diagnostic aspects of the pain, eg 'it hurts much more when I do this, what does it mean?' 'Oh that's normal, take two of these and call em in the morning.' 'Grrrr.'

Exercise is very useful, But of course you feel demotivated. You could try to put in some effort finding what kind of exercise options are available. I find the idea of going to a regular gym insufferably dull, for example, but I enjoy climbing and martial arts, and you should be able to find options for both in any large city. Martial arts has a lot going for it because it gives you a simple problem to focus on - how to prevent your opponent from beating you up- but with the benefit that the opponent isn't trying to make you feel bad, so you don't need to take his or her assaults personally. If you investigate this don't go for a place that is heavy into competitions and belts and other stuff, look up the sort of people who do small tai chi classes in parks and so on. As a general rule, the less rent someone has to pay the more personal attention you'll get. Of course you don't have to go with an Asian martial art, if you've always wanted to learn fencing or something try that. The basic point is that it's really helpful to have something or someone external to grapple with, it takes you out of yourself. Also,as you learn more skill you can exercise mentally by running through sequences of different moves in your mind, like a chess game. This is very good for managing feelings of negativity and worthlessness, after a while you recognize patterns of unhealthy thought and learn to short-circuit them.

You could also consider getting a pet, particularly a dog. Now matter how shitty you feel, being responsible for another creature kind of forces you to get out of bed int he morning. Of course it comes with annoyances an irritations too, from cleaning up occasional toilet accidents to their refusal to take no for an answer when you don't want to get out of bed. But they're manageable problems. On the flip side, they give you an excuse for managing your life more rigorously; if you can function more consistently at work, then you can also say you need to go at the end of the day because you have to feed your animal. Some workplaces will allow you to bring in a service animal, and if animal companionship is helpful to you than you have very strong rights under the Americans with Disabilities Act (I'm assuming you're in the US). Use them. If you're already had an animal in your childhood then you know what you like, if not then get some advice. Dogs are generally more emotionally responsive than cats, plus they're more familiar as service animals, so unless you're already a 'cat person' a mid-size dog is a better choice. They're more work than a cat, but that is a Good Thing because it will get you out of the house.

Work-wise, maybe programming isn't for you. I got quite alienated in my 20s by the virtuality of programming; you're pushing stuff around in memory or in the cloud somewhere, shoveling bits to make $ and after a while it all seems rather meaningless and pointless if you're not solving a problem that you actively care about. Also, the never-ending stream of New! Stuff! coming fown the pipe (frameworks, protocols etc.) means that your knowledge base is being constantly degraded, which just gets a bit tiring after a while because unless you're writing for mainframes you may well feel that you're building on sand, an this becomes an Unpleasant Metaphor for Life, of the sort you can easily obsess over when depressed. Start asking yourself what else are you interested in besides code? If you weren't a programmer, what sort of things would you engage programmers to do? Let your imagination roam - run a winning formula 1 team? reduce world hunger? Solve humanity's most ancient mysteries? Bear in mind that outside of pure computer science, a lot of programming is service work - skilled service work, but still service work. It's like being an accountant - you have to be smart and on your game, but ultimately you're a functionary rather than a decision maker in many programming jobs. Just because you're good at it doesn't mean you have to do it for the rest of your life. The mental skills of programming are highly transferable to many other contexts, and you may very well find it profitable to move into a different domain and build up a pile of expert knowledge there, where you will also find new and interesting problems that could be easily solved by technology, allowing you to progress very quickly by being The Smart Person.

So as an exercise, imagine that you were fired and further imagine that you were put on some sort of programming blacklist and forbidden from working in the tech sector, forced to work in some other context as an underground programmer. What other fields are you interested in? Protip: while some highly specialized subfields like medicine obviously require significant qualifications to enter and would require you to go back to school for many years and at great expense, many interesting and exciting areas require no qualifications at all, just a capacity for obsession. You already have one of those, it's what makes your depression so intense. When you find something, start learning about it intensively outside of your day job; use the latter to finance your actual interest. You shouldn't feel the least bit guilty about this.

Of course, you don't have to leave programming. but you do have to know why you're in it, and that means it's important to be programming to some end that you are interested in. Who is it that decides what sort of programming problems you work on, and if that is not you, then why not? I have the impression that you derive a good deal of your self-worth from your job, and are disproportionately sensitive to how you do there, not least by the proximity of how you discuss your job situation with questioning whether you deserve to be alive (by the way, the answer to that question is that you don't, but neither does anyone else - you just are, and you don't owe anyone an apology for your existence unless you deliberately dedicate yourself to making other people feel awful). Shift your perspective to thinking about how you perform a service so they give you money, and focus on what other things you would like to do with money besides pay rent and put food in your mouth. This will help you get through individual bad days - it is perfectly OK to have an ulterior motive for work. Obviously don't say out loud that you're only there for the money, but start thinking of your line of work as a ladder to get to somewhere else you want to go.