Students walk to the dorms at Carnegie Mellon University in Pittsburgh on Aug. 23. The university is actively recruiting female students into the STEM curriculum. (Katherine Frey/The Washington Post)

— Women are making major gains in enrollment in engineering and computer science at some of the nation’s most prominent colleges and universities, a breakthrough that shows that gender parity is possible in technology fields long dominated by men.

More than half of engineering bachelor’s degrees at the Massachusetts Institute of Technology went to women in 2015, federal data shows. The same was true at Dartmouth College this year. The majority of computer science majors at California’s Harvey Mudd College are women. Here at Carnegie Mellon University, women account for nearly half of first-year computer science students — 48 percent, a school record.

A bridge linking the Gates Center for Computer Science to one of the fine-arts buildings at Carnegie Mellon. (Katherine Frey/The Washington Post)

These and other examples underscore an evolution in fields vital to the nation’s economy. While men still far outnumber women nationally — 4 to 1 in engineering, 5 to 1 in computer science — female students are gaining ground slowly at many schools and rapidly at others. The shift gained attention last year when women fed up with gender stereotypes posted photographs of themselves on social media with a hashtag that went viral — #ilooklikeanengineer.

The federal government and industry leaders acknowledge that more should be done to bring women into science, technology, engineering and math, known as the STEM fields, and they have pushed programs such as Girls Who Code to boost interest among girls at a young age. Educators caution that many female students continue to face obstacles, including biases from classmates, teachers and others who might cause them to doubt their potential.

“There is systematic exclusion,” said Maria Klawe, Harvey Mudd’s president. “It used to be very deliberate, very conscious. I think it’s now much less conscious.”

Klawe, a computer scientist who is the college’s first female president, said that, for generations, talented women in STEM fields experienced “really annoying” snubs from men. But Klawe said she is seeing “significant progress” for female students at many schools, even as the gender gap remains wide across the country.

In 2015, about 20 percent of bachelor’s degrees in engineering and 16 percent of those in computer science went to women, according to federal data. Those shares were each up two percentage points compared with five years earlier. At that rate, it could take decades to reach parity.

But some schools are making gains faster than others. Women earned at least a third of the engineering degrees at 31 schools in 2015 when considering schools that award 20 or more degrees a year in the field. Women reached that threshold in computer science at 16 colleges and universities.

Women in engineering and computer science

The table below shows the number of bachelor’s degrees in engineering and in computer science awarded in 2014-2015 at colleges and universities, as well as the share of those degrees earned by women. The data was obtained from the federal Integrated Postsecondary Education Data System. Click here to see the full sortable table.

Selective private schools, especially the most prestigious, hold an edge over public universities in the quest for gender balance. Those with lower enrollment and huge pools of qualified applicants often have wider latitude than state schools to use admissions to remake their gender profile.

Incoming first-year students learn a dance as part of orientation at their coed dorm at Carnegie Mellon University in Pittsburgh. The school has seen its gender ratio equalizing. (Katherine Frey/The Washington Post)

First-year engineering student Priscilla Chung, 18, left, and Annette Chen, 20, an information systems major, join in a game of ultimate Frisbee on the Cut at Carnegie Mellon. (Katherine Frey/The Washington Post)

Samantha Horry, 18, from the suburbs of Philadelphia, is one of 80 young women among 165 new computer science students this fall at Carnegie Mellon. She fell for the subject in high school, taking eight classes. Almost always, she was the only girl. “Just me and some guys,” she recalled.

That didn’t deter her from winning admission to one of the country’s most prestigious programs to pursue her interests in machine learning and artificial intelligence.

Now Horry is startled at how many young women on campus are following her path in a field where the stereotype of the male teenage computer geek, obsessed with gaming and programming, looms large. She looks around in class and sees, for the first time, gender balance.

“It’s crazy and awesome,” Horry said. “I don’t feel out of place.”

Samantha Horry, a first-year computer science major, checks her email in her dorm room at Pittsburgh’s Carnegie Mellon University on Aug. 24. (Katherine Frey/The Washington Post)

Public schools have been moving more slowly toward gender equality in engineering and science. At the University of Maryland, about 21 percent of engineering graduates and 15 percent of computer science graduates in 2015 were women. Those figures were close to the national averages. But university officials said they have reached out intensively to public high schools to spread the message that engineering and computer science are open to all.

“When you talk with young girls, they want to make a difference in the world,” said Paige Smith, director of the Women in Engineering program at College Park. “They want to help people.”

Engineers do that, Smith said, working on “everything from the food we eat to the houses we live in to the water we drink. We really do try to make it real for them.” The female share of engineering graduates at College Park held steady from 2010 to 2015, while the female share of computer science grads rose seven points, even as the fields exploded in popularity.

The University of Washington, near Microsoft’s Seattle-area home, had the largest share of women in computer science among the nation’s public flagships and some of the largest five-year gains. Thirty-two percent of its graduates in that major were women in 2015, up 11 points in five years.

Ed Lazowska, a computer science and engineering professor at the university, said it is crucial to ensure that introductory courses are engaging for all students, especially those who might struggle at first because they are new to the subject. “If your intro course tries to weed people out, then the people you’re going to weed out are precisely those that are underrepresented in the first place,” Lazowska said.

Role models matter, too, especially for fields in which male professors far outnumber women. Dartmouth’s engineering dean, Joseph Helble, said the college has sought to diversify its faculty and ensure that engineering students work with as many female teaching assistants and project advisers as possible.

MIT’s engineering dean, Ian Waitz, said schools must guard against gender discrimination. “Things have gotten better,” he said, “but these problems haven’t gone away.”

He cited a recent survey of electrical-engineering and computer science students at MIT that found women tended to harbor more doubts in their abilities than men and that some women felt negative bias from their peers.

Jelena Kovacevic, head of the electrical and computer engineering department at Carnegie Mellon University, talks about gender and her field on campus on Aug. 23. (Katherine Frey/The Washington Post)

At Carnegie Mellon, the head of the electrical and computer engineering department recounted one of her own experiences with male ignorance. Jelena Kovacevic said that after she earned her doctorate in electrical engineering from Columbia University in 1991, she was invited to speak at a conference. She arrived at the location and started preparing. “I could see everybody was ignoring me,” Kovacevic said. “Then a guy asked me, ‘When’s the speaker coming?’ I said, ‘It will be any minute.’ ” Jaws dropped when the audience figured out she was the one. “I thought it was funny,” she said.

Kovacevic said small gestures can make a larger point. When she is running a meeting, she typically asks a male colleague to take notes, pushing back against the notion that secretarial tasks should go to women.

Thirty-six percent of Carnegie Mellon’s engineering undergraduates are women. The share is higher for first-year students: 43 percent. Female students are the majority in chemical engineering and civil and environmental engineering. But in Kovacevic’s department, just 27 percent are women. Her strategy to raise those numbers is to make the subject as exciting for students as it is for faculty members.

“The culture is paramount,” she said. “We do it because we are passionate about it.”

Alina Rath, a senior electrical and computer engineering major. She is vice president of Women in Electrical and Computer Engineering at Carnegie Mellon. (Katherine Frey/The Washington Post)

Ariana Weinstock, a senior computer science major at Carnegie Mellon, left, introduces herself to first-year computer science major Mera Tegene on Aug. 23. (Katherine Frey/The Washington Post)

University leaders say their push to bring more women into computer science and engineering began years ago and required a multi-pronged strategy — reaching out to high schools and middle schools, diversifying the faculty, pairing young female students with older female mentors, expanding anti-bias training and more.

Andrew Moore, Carnegie Mellon’s dean of computer science, said he called and met with a prospective student named Mera Tegene last spring to discuss her interests in chemistry, computer science and virtual reality. Tegene had been admitted to Moore’s program but had not yet accepted. Moore was eager to recruit the 18-year-old from Dallas.

The dean persuaded her, she said: “That was the decision point.”

Tegene said that while in high school, she and a friend often amused themselves at computer science contests by counting the number of girls in the room. The gender ratio was always lopsided toward boys. At Carnegie Mellon, Tegene still plays the game.

“It’s usually even,” she said. That eases her mind, because she doesn’t feel like the only person in class representing an entire group. “I can be myself.”

First-year students at Carnegie Mellon University at an orientation-week show on Aug. 23. (Katherine Frey/The Washington Post)