Monday, July 28, 2008

Women and the Quality of Code

This article was originally written for

A good way to stir up some controversy is to bring up possible differences between the way men and women write code. Add to it a tone that suggests that women write better code, and you’ll really get people talking. Is there something to it? Would you really be able to tell the difference between male and female code, and could you really say that one is better than the other?

Programming computer applications involves writing multiple lines of instructions that will be turned into something a computer can understand. When writing these instructions, or code, a programmer can also add extra information that the computer will ignore, called comments. To get a bit of an idea of what code is all about, go to ‘View, Page Source’ on your browser to see what a web page really looks like. When we ask about the differences between code that men and women write, we are talking about what instructions are used, what style is used to write them, and what kinds of comments are included.

A story was recently featured on Slashdot, a news website geared towards nerds like us, called Men Write Code from Mars, Women Write More Helpful Code from Venus – I think you’ll probably agree that even the title sets the ‘women are better’ tone! This article describes how “Emma McGrattan, the senior vice-president of engineering for computer-database company Ingres – and one of Silicon Valley’s highest-ranking female programmers – insists that men and women write code differently.”

Apparently, McGrattan believes that women’s code tends to include more useful comments than men’s. She says that women use comments to explain what they were thinking when writing their code so it is easy to understand by programmers that haven’t seen it before. On the other hand, she suggests that men actually try to make their code more cryptic, with fewer useful comments, in an effort to show how clever they are. To help fix this problem, she set up rules and standards for Ingres programmers to follow, forcing everyone to document their code, and any changes they made to other peoples’ code, with detailed comments.

The comments section back at Slashdot has some interesting reaction. One reader says:

It’s now well established that the human brain builds negative stereotypes more easily than positive ones and that people see what they are expecting and apply a double standard. This person sees what she wants to see.

Another points out:

Personality is complex, not binary. I know many girls that code beautifully, and many more that can not code at all.

The general theme throughout the comments is that men and women do think differently, but that neither writes better code than the other, nor could you really tell the difference arbitrarily.

Interestingly, there seems to be a good selection of research trying to determine whether men and women write English compositions differently. One study concludes that “there are indeed different strategies employed by men and women in setting forth information and especially in encoding the relation between writer and reader in texts.” In other words, there are apparently several indicators that can help decide fairly reliably whether a text was written by a male or female, such as the number of personal pronouns (I, we, you) used in place of noun specifiers (much, some). Could this difference extend to how men and women write code, too?

From my own job experience in two different companies, I can say that I was very careful to write useful comments, and was even complimented for it. While some of the guys did occasionally forget to add in the same kind of detailed comments that McGrattan is asking for, many of them wrote just as many comments as I did. On the flip side, some of the girls I worked with barely wrote any at all! In my case, it really did seem to depend on the person, not the gender.

So what’s the answer to the question of whether women write better code than men? And is it possible to tell the difference between women’s and men’s code just by looking at it? There may be some noticeable trends like those found in English composition, but this has yet to be scientifically studied as far as I know. Besides, until women make up a little closer to half of the programming workforce, how can we do a fair comparison? I think we’ll have to mark this one down as inconclusive for now, though I’m leaning toward a no for the part about women writing better code. What do you think?


Puraz said...

I don't think I could tell the difference between code written by a men or women... It really depends on the person, rather than gender.

I write clean code - it might not be the most efficient at times, but it's always well documented, and well spaced/aligned.

Again, quality of code isn't very quantitative right? We can't put numbers to it - it's in the eye of the beholder.

Gail said...

"Again, quality of code isn't very quantitative right?"

So true. We'd be more likely to be able to find other differences in terms of, perhaps, style of variable names (do men or women tend to use full words more often?), or number of functions written for more complex tasks (does one sex end up leaving it in a big chunk, or break it down?). But really, until there are more women in the industry, there's not much point in comparing, is there...

Puraz said...

Exactly.. If we put more concrete boundaries as to what constitutes good and bad code we could measure that, but still some of those are subjective... length/complexity of function blocks.

I'd be curious to actually see the results of a study like this. There is a lot that could be learned from this. We could find ways to help both men and women write better code.

Also a good psychological study to see why things are one way or the other.

If I was to take a random guess with regards to the results of the study, I'd say that they would be inconclusive. I don't think a pattern exists... but then again, I haven't been exposed to much code written by women.

Post a Comment

Comments are moderated - please be patient while I approve yours.