I don't think this is at all unique to CS, or even to technical fields: it's the Dunning-Kruger Effect all over again.
Regarding women in CS, it would go a long way in helping to simply treat them as people. As an IRC op, I find it sickening how often, particularly in online programming communities, people hear the word "female" and start acting like utter idiots. This results in both unwanted negative and positive attention: but furthermore, continually reinforces the idea that a female is some sort of odd, unusual creature deserving of special study. This doesn't merely bother the victims -- it also helps convince them that they're the odd one out, and that they don't belong.
This doesn't have to be blatant sexism -- it can simply be comments like "oh, you're a girl?!" when someone uses a female pronoun. I've seen this happen dozens times in a single channel in response to a single person over the course of a few months.
Some of you may be thinking that this is just a problem for 4chan and Reddit. But the interesting thing that I've noticed is that the incidence of this problem doesn't seem to be reduced much with more professional communities, or in more mature environments.
Rather, the only statistic that seems to be consistently correlated with these kinds of problems is the perceived male/female ratio in a community. The instance the perception gets created that "this community is almost entirely male", problems begin to occur. This seems to be a constant everywhere from programming communities to writing communities to roleplaying communities to fandoms.
If you're male, you've probably been responsible for some of this at some point. Maybe it was just one comment. I mean, what harm could one comment do, right? But a hundred people making "just one comment" stops being a joke quickly -- and instead makes half of the smart aspiring programmers out there feel unwelcome. This is of course self-reinforcing: by making women feel unwelcome, the "almost entirely male" perception is perpetuated.
(An interesting question might be why the reverse problem rarely exists in communities perceived to be almost entirely female.)