It is a great motivator, this feeling of confidence. This belief that we can accomplish what we want to do is called self-efficacy. There are four sources of self-efficacy at a particular task (in order of strength):
- doing it
- seeing people like me do it
- social persuasion
- your body
1. doing it: If you try something and have success, this is the best source of a feeling of self-efficacy. In my generation, more boys than girls started programming at an early age.
2. seeing people like me do it: If my mom can do it, so can I.
People choose careers by picturing themselves in that job, and the picture is based on people we know. If we can't picture ourselves in a career, we don't consider it. The gender dichotomy is strong in our culture, a big part of whom we consider "like me." A boy can picture himself as a programmer. When a girl looks around, she doesn't see people like her coding, attending conferences, speaking, blogging, contributing to open source. Even women developers: looking up in the hierarchy, they see themselves in management, analysis, QA, BI, maybe DBA. Not system administration. Not architecture.
3. social persuasion: Do my friends approve of it?
Here, we look not at the culture of programming, but the culture of women. When I go to Kindergarten Moms Night and someone asks what I do, "computer programming" usually ends the conversation. I don't fit in. Growing up and being grown up, if you enjoy the company of other women, the social persuasion is against development.
4. your body: Do you get a good feeling in your stomach? I don't know about this one. Is it different for men and women?
Women are just as capable of programming as men, but (in aggregate) they don't feel as capable. If we can change that, then we can change the ratio.
#1 is the most direct route, and many in the community are working on introducing programming to young people, especially young women. Yay for them!
#2 is something else we can change. Increase the visibility of women who are already developers, especially those at the highest level. I want to look up, up on stage or up the decisionmaking structure, and see people like me. Conference organizers who go out of your way to elicit proposals from women, thank you. You're helping.
#3 comes the larger social culture, not the culture of programmers. I can't be a typical mom and a community-involved developer. This is not something the programming community can change. Personally, I see #3 as the most intractable obstacle for women.
As a community, #1 and #2 are the ones we can do something about. And hey, they're at the top of the list! If we keep working at this, we'll reach s critical mass. Once programming is (say) 33% women, then #3 will fix itself. Without intervention, the social pressure and lack of role models combine to attract and retain fewer and fewer women. With work, we can turn that spiral around.
 At PyCon Canada, Mel Chua gave a great talk on learning. This list is hers.