I have the theory that boys get into programming as a form of escapism – because the external world is frustrating to them. It is certainly my case, external world has all sorts of illogic demands, things that exist but should not be explicited, social rules, or various insults and condescension, some of them because we’re boys (my sister used to tell me boys have 13% fewer neurons, that’s why we’re stupid). So we talk to computers, although they can be extremely frustrating (I have spent hours at 7 years old finding the missing brackets — all of this in 1990 when I didn’t even speak English), but at least computers are logic. And they answer to us. They don’t make snarky comments. At least, when it fails, _it’s our fault_ . And we can fix it.
That would easily explain the gender gap in programming. It’s an escapism from the real world, while girls don’t need it as much because a lot of people are mindful of girls’ problems (notably teachers), or accept to listen to them.
I’d like to see an experiment: Give children 90% male teachers (the opposite of today’s ratio) and see whether programming then becomes more popular among girls than boys.