Miyamoto Musashi:
> The primary thing when you take a sword in your hands is your intention to cut the enemy, whatever the
means. Whenever you parry, hit, spring, strike or touch the enemy's cutting sword, you must cut the enemy in
the same movement. It is essential to attain this. If you think only of hitting, springing, striking or touching
the enemy, you will not be able actually to cut him. More than anything, you must be thinking of carrying
your movement through to cutting him. You must thoroughly research this. [1]
I've been able to experience the flow for as far as I can remember. It was years before anyone even told me it even had a name. I've read the wikipedia article [2], but not the actual book. So I'm not an expert. But as far as I can tell, reaching the flow involves knowing your goal, closing the feedback loop, and pouring all your attention toward the goal.
For example, consider reading a novel (written in English). Someone who can't read English obviously won't be able to read it. But for someone who speaks English as a 2nd language, sure, they'll be able to read it. But more slowly since they have to think about things which are non-central to reading. Things like syntax, spelling, idiomatic expressions, irregular verbs, conjugations, etc. I.e. the implementation details; the cruft. The non-central things get in the way of the important things, which include semantics, plot, character development, irony, point of view, theme, tone, mood, etc.
Personally, I see novels (and sometimes non-fiction) as a gateway. As in a gateway into another universe. Because for one reason or another, I don't struggle at all with piercing through the syntax or get the slightest bit fatigued (though technical documents are different, those take effort for me). But I think that for some people (even for whom English is their primary language), text represents a barrier. "Why not just watch the movie?" Rather than using the semantics to simulate this alternate universe, they get bottle-necked into trying to translate the glyphs. So where I see as an epic space battle, others see an intimidating bulwark of text.
Because some people have this mental image, guys like Chris Granger have been trying to figure out how to translate a wall of text like a C source file into a novel's equivalent of a movie. We've gotten a lot of cruft out of the way with higher level languages, but it's not enough because programming still text based. I don't know if it'll work out, but that's the ideal.
The second thing is the feedback loop. Feedback has to be immediate. The feedback also has to be exact. I.e. you've got to know your craft better than the back of your hand. A musician will know in real time how well they are performing. They don't just notice the obvious mistakes, but even the minutia like jliechti1 was discussing. And they have to be confident about knowing that they indeed made a mistake so they can immediately act to correct it. The reason feedback comes second is because if you're still bushwhacking through a jungle of cruft, the feedback loop won't ever feel instantaneous.
Another analogy is being able to unwind the recursion without having to plug and chug each step. There's simply no effort expended. You can model the function well enough that you can visualize the path it takes, like the chess master could in the article. You simply cut through to the base case.
I like the Musashi quote because it perfectly embodies the first two items. The goal is to win the fight. But some people get caught up in thinking too much about the techniques. E.g. parrying is useful. But if you don't understand how to take advantage of it, it's mental cruft [3]. Additionally, if you're not confident, you'll hesitate and probably die. The stakes aren't as high in programming, but the same idea applies: perfect mastery is only a prerequisite to achieving the flow.
Third is the focusing of attention. It involves a state of mind where you're naturally able to block out all distractions, and focus everything on the task at hand. This part is a little like falling in love: you can't force it, you have to set the right conditions and pray things simply work out. This part is really frustrating compared to the first two items. You can always review your specs to better understand the goal and constraints, and maybe philosophize a bit. You can always practice and acquire skill in order to better fine-tune the feedback loop. But when it comes to focusing attention, all you can do is remove distractions. Which sounds ironic since "why would I want to block out distractions if I've removed them already?" I don't know how to explain it better, but that's how it works for me.
Interruptions are the worst. If you go out to lunch for an hour but you're still pondering the problem, then flow won't necessarily break. But if someone asks you to help them move furniture for 3 minutes, that forces a context switch and everything collapses like a house of cards.
Cthulu below mentions something about growing up in the proverbial basement. I think there's a lot of truth to that. Basements = zero distractions. Maybe childhood better conditions some people for the flow than others. But I did notice that once I heard the name "flow" and realized I already experience the emotion on a common basis, I was able to (try to) actively graft it into other activities. I think being able to actively seek it out helps. So I think it's at least somewhat trainable.
So here's a recap. In order to achieve the flow: master your craft; tighten the loop; avoid distractions.
[1] http://www.uvm.edu/~asnider/IDAS_2011_CD/Teachers/Steve%20Ll...
[2] http://en.wikipedia.org/wiki/Flow_(psychology)
[3] http://starwars.wikia.com/wiki/Form_III:_Soresu