MEDFORD -- As a young high school teacher in 1982, Diane Souvaine leapt into graduate school for computer science having taken only one class in the subject.
Computers, she believed, offered an exhilarating way to apply her math skills to real-world problems. And because computer science was coming into its own in the feminist age, she also hoped it would be more welcoming to women than her undergraduate math department.
Today, Souvaine chairs the Tufts University computer science department, which has more female professors than male. But few younger women have followed in her generation's footsteps. Next spring, when 22 computer science graduates accept their Tufts diplomas, only four will be women.
Born in contemporary times, free of the male-dominated legacy common to other sciences and engineering, computer science could have become a model for gender equality. In the early 1980s, it had one of the highest proportions of female undergraduates in science and engineering. And yet with remarkable speed, it has become one of the least gender-balanced fields in American society.
In a year of heated debate about why there aren't more women in science, the conversation has focused largely on discrimination, the conflicts between the time demands of the scientific career track and family life, and what Harvard University President Lawrence H. Summers famously dubbed ''intrinsic aptitude."
But the history of computer science demonstrates that more elusive cultural factors can have a major impact on a field's ability to attract women.
As the popularity of computer science soared in the first half of the 1980s, many university departments became overburdened and more competitive, some professors argue. Introductory classes were taught in a way that emphasized technical minutiae over a broader sense of what was important and exciting about the field, a style catering to the diehard -- and overwhelmingly male -- techies rather than curious new recruits. The last thing educators, besieged by students, worried about was attracting more, so they didn't see the need to combat the image that took root in popular culture of the male computer geek with poor hygiene and glazed eyes.
''We had so much interest from so many young men for years, the attitude was 'Oh my God, how are we going to cope with these hordes of students?' not 'How do we get them interested?' " said Maria Klawe, a computer scientist and dean of engineering at Princeton University.
Though the enormous impact of computers on society makes the development of computer science at the college level unique in some ways, some scientists believe it offers a warning to other sciences as well. In fact, something similar happened in physics after World War II, when the atomic bomb catapulted the subject to preeminence in society, according to David Kaiser, a physicist and historian of science at the Massachusetts Institute of Technology. Facing a sudden and dramatic rise in enrollments, physics departments grew less intimate and coped with the crowds by teaching the subject in a more routinized and less creative way.
The percentage of women studying physics, already low, dropped dramatically and stayed in the single digits for decades. Eventually the physics bubble burst for men as well, and today a high percentage of the country's physicists are foreign-born.
Some computer scientists fear that they may be going in the same direction. They view the dearth of women as symptomatic of a larger failure in their field, which has recently become less attractive to promising young men, as well. Women are ''the canaries in the mine," said Harvard computer science professor Barbara J. Grosz.
In the wake of the dot-com bust, the number of new computer science majors in 2004 was 40 percent lower than in 2000, according to the Computing Research Association. The field has seen ups and downs before, and some think the numbers for men will soon improve at least a bit. But the percentage of undergraduate majors who are female has barely budged in a dozen years.
The shortage of new computer scientists threatens American leadership in technological innovation just as countries such as China and India are gearing up for the kind of competition the United States has never before faced.
The US economy is expected to add 1.5 million computer- and information-related jobs by 2012, while this country will have only half that many qualified graduates, according to one analysis of federal data. Meanwhile, the subject is becoming increasingly intertwined with fields ranging from homeland security to linguistics to biology and medicine.
''People who are mapping the genome are really computer scientists involved in biology," said Lenore Blum, a professor at Carnegie Mellon University in Pittsburgh.
A Globe review shows that the proportion of women among bachelor's degree recipients in computer science peaked at 37 percent in 1985 and then went on the decline. Women have comprised about 28 percent of computer science bachelor's degree recipients in the last few years, and in the elite confines of research universities, only 17 percent of graduates are women. (The percentage of women among PhD recipients has grown, but still languishes at around 20 percent.)
The argument of many computer scientists is that women who study science or technology, because they are defying social expectations, are in an uncomfortable position to begin with. So they are more likely to be dissuaded from pursuing computer science if they are exposed to an unpleasant environment, bad teaching, and negative stereotypes like the image of the male hacker.
When Tara Espiritu arrived at Tufts, she was the rare young woman planning to become a computer scientist. Her father is a programmer, and she took Advanced Placement computer science in high school. Because she scored well on the AP exam, she started out at Tufts in an upper-level class, in which she was one of a handful of women. The same men always spoke up, often to raise some technical point that meant nothing to Espiritu. She never raised her hand.
''I have not built my own computer, I don't know everything about all the different operating systems," she said. ''These people would just sit in the front of the class and ask these complicated questions. I had no idea what they were talking about."
Now a junior, Espiritu is majoring in engineering psychology, which examines how product design affects human use.
The classroom experience that turned off Espiritu had its roots in the early 1980s. The number of students receiving bachelor's degrees in computer science more than doubled between 1981 and 1984, according to the National Science Foundation. ''Undergraduates are swarming to major in computer science," NSF official Kent K. Curtis warned in 1983. Combined with the problem of faculty leaving for better-paying jobs, that meant there weren't enough professors to teach the subject. In response, ''many institutions are being forced to limit enrollments," Curtis wrote.
Many computer science departments imposed GPA requirements or tried to make introductory classes more difficult in order to weed out the multitudes, said Stanford professor Eric Roberts.
Those who were driven out were not the worst students, but those who felt more marginal, Roberts argues. They could have been men or women, but studies have shown that women generally have less previous computing experience and less single-minded passion for technology.
Introductory classes zeroed in on programming and other technical aspects of the field, rather than explaining big ideas or talking about how computing can impact society, many professors say. That approach led to a misconception among students that computer science is the same thing as computer programming. Computer scientists say that view shortchanges the field, which is far broader and more intellectually rich. It is applied math and design, they say; it is about modeling human behavior and thinking about the simplest way to accomplish a complex task.
When Souvaine joined the Tufts faculty in 1998, she was dismayed that there were few female students in the introductory course. So she and a colleague designed a new freshman seminar focused on problem-solving and real-life applications.
On a recent afternoon, Soha Hassoun, who is now teaching that class, lit up a drab cinder-block classroom with her boisterous questions. The topic of the day was how to get a computer to determine whether a particular point is inside or outside a geometric shape.
Hassoun's focus was on logical thinking, and she set aside only a few minutes for students to write their answers in computer code.
''Here's the big question. Why do we care about this?" she asked rhetorically, then went on to explain that that same method could help determine which diabetes tests are the best predictors of the disease. The class would later work on just that task.
The first time Souvaine taught the freshman seminar, there were 14 men and 14 women, and seven of each gender went on to major in the field. The number of female undergraduate majors remains low, but Souvaine sees reason for hope. About 30 percent of students now in lower-level classes are women.
On a broader level, the National Science Foundation will soon announce a new set of grants to universities, high schools, and industry groups with creative ideas for attracting women to computer science. A two-year-old organization called the National Center for Women & Information Technology has designated several schools and groups, including the Girl Scouts, to identify solutions.
A number of universities are trying to do something similar to Tufts. At MIT, where the percentage of women is much lower in computer science than in the general student body, the electrical engineering and computer science department will pilot two new introductory classes this spring. One will use robots to try to capture the excitement of the subject, and the other will provide basic background aimed at students who didn't take Advanced Placement computer science in high school.
The goal is to inspire more students like Katie Seyboth of Tufts. She loved math and science, but had never been interested in computer science before she took, on a whim, one of the school's introductory classes for people with no previous experience.
Soon, Seyboth was procrastinating on her other class work in order to do computer science assignments. Still, she found it ''really intimidating" when men used terms she didn't know and talked about complicated programs they wrote in their free time.
She believes that if she hadn't taken the ''welcoming" introduction, she would have drowned in her next class, which was all programming. If Souvaine hadn't taken her under her wing, she might not have had the courage to drop her chemistry major, she said.
Now a senior, Seyboth wants to earn a doctorate in computer science and recently interviewed for a job at Google. She was just named a finalist for a national computer science award.
''There's nothing better than watching the real potential of students like Katie being unveiled, seeing the joy and excitement they feel and the contributions they make," Souvaine said. ''And yet, had just a few things gone differently along the way, they might no longer be in the field."
Marcella Bombardieri can be reached at bombardieri@ globe.com.