I find being in the right frame of mind is more important than location. I code at my desk, I code on the sofa, I code on public transport, I code at the pub if I get there before my friends, I code in bed in the middle of the night if I cannot sleep.
Sometimes I need to listen to music to block out distractions. Sometimes I don't.
You say that "it seems like some places and times are better than others to the programming mind." That's true, but it's also dependent on the programming mind in question, both in terms of different people having different optima, and individual people having different optima over time.