I've been struggling with motivation a lot over the last few years.
I started teaching myself to program about 5 years ago, and I've gone about it in a very scattershot way. This is overall not a bad approach when you're starting out, because you don't know what you don't know, so diving in and just exploring the terrain is going to show you what you need to know to make a reasonable judgement about where you want to go, but I think I stayed in the scattershot mode longer than I should have and wasted a lot of time doing trivial things in various domains. Most of the difficulties in programming exist in the higher layers of complexity, not in the low-level logic or syntax, so retracing low level logic in different areas is pretty much spinning your wheels. I think that asking yourself to be efficient when you don't know what you're doing is kind of absurd, though, and my grasp of "the greater universe of programming" is stronger than it would have been if I just dug in deep in one particular domain.
I had the same experience with philosophy when I devoted myself to "learning philosophy" for about 7-8 years. Philosophy is too big to "learn" in a lifetime, so you have to winnow in at some point, but when you're starting out the scattershot approach is actually going to save you time; you learn the rough geography of philosophy and then find a valley to build your homestead.
I've had many of the same problems with learning programming as I had with philosophy. I've moved in fits and starts with programming and some months over the course of those years I haven't gotten anything done; with philosophy I had the same "static months." With philosophy it was easier, though, because there was never an objective within learning philosophy that wasn't me-centric; I wanted to learn how to think about the world and it had nothing to do with finding a job, paying my rent, etc.
With programming my intention has always been to find a job and get paid to get better at it. I'm getting to the end of my exploratory phase, and I probably should have been able to find a job by now, but I keep putting off building things that I can show people and say, "look, I get this. I can talk you through it, I've used best practices where applicable and I have a good grasp of the technologies that I'm leveraging."
For me this is where motivation gets really confusing. I like learning, I frequently like doing, but as soon as I cast things in the light of a "portfolio project" or something I can hand over to a recruiter my motivation evaporates. I think I'm just very averse to going into an interview where my chances are slim, trying to prove myself despite my lack of credentials, and this is really frustrating. I feel like I'm pacing back and forth in front of a gate, and I refuse to knock and see if they'll let me in: You could just knock and see what they say. It's not the end of the world if you don't get through on the first try. But I just can't summon the... courage, I guess? ... to be told "you're not good enough." I know that I'm good enough, but I don't want to try to show it, and I'm struggling to either figure out why or just blast through and make a run at it.
The reasonable thing to do would be build a portfolio project and plaster the world with my CV, and I've been trying to do this. I've built a website, and all that's left is to string all the pieces together, but it's an ambitious project and in order to finish it in a timely manner I have to give up on some things that feel "right." (Faking backend data, letting the design be "ok" rather than ideal, truncating the features to something manageable, but sub-deal.) When I treat it like a start-up my motivation is there to be utilized, when I think of it as a portfolio project I have to give myself a schedule, dig in my heels and push like hell. This hasn't been efficient and I feel like I should have been done with this months ago. ... and here I am on the hubskies dragging my feet.
Anyway, the only thing that really worries me is the idea that I'll stop, I'll start a different project, and I'll not ever have something to show for all the time and effort. As long as I keep making some progress I'm still moving forward, and this is how I try to treat things when I can't force myself to open my terminal and whack some code together.
Anyway, I'm afraid of that gate. I'm not afraid of what's on the other side, it's just the gate that mind fucks me. I don't want to be told I can't take part in the reindeer games, but I'm pretty sure I'd be great at them.
It's stupid and frustrating, but that's how things are sometimes. I'm going to a pair-programming meet-up in August as a way to break into the programming community, and I think this will help take away some of the fear I have about being judged, or feeling inadequate (as well as introduce me to collaboration and what that means for a programming project; something I haven't approached yet that is also undoubtedly important.) As a socially apt person it's really weird to go through this self-doubt and anxiety, but I think I'm learning things about myself that I've avoided learning because they're uncomfortable to work through. Why does that damn gate intimidate me so much? Just finish the project and knock on the gate. It's that easy.
Anyway, writing it all out has made me look the problem right in the face. At the end of the day I'm making slow progress, and slow progress will get me there eventually. I just wish I'd gotten there yesterday. :)