New York — High school senior Geraldine Agredo fell in love with computer science in a surprising setting: her ninth-grade Spanish class. There, she learned to code in order to build games that teach simple Spanish lessons.

Coding “was a logical way of thinking” that she could apply to constructing essays and other schoolwork, she says. She’s now planning to major in computer science in college.

There’s much talk these days of a gender gap in STEM (science, technology, engineering, and math). One way educators are tackling that gender gap is by creating all-girls public STEM schools. Geraldine attends The Young Women’s Leadership School of Astoria (TYWLS, or “twills,” as they call it) – part of a network of five such schools in New York City that is often looked to as a model for public girls’ schools around the country.

Backers of these schools say they offer a choice to urban, low-income girls that has long been available to their wealthier counterparts. They say the culture of sisterhood and college prep at these schools is empowering girls to march confidently into fields where they have long been underrepresented.

Geraldine believes the all-girls setting has helped her. Before starting at TYWLS in sixth grade, she says, “there were times [in class] when I would be about to say something, and I would stop and be like, ‘Hmm, what would the guys say?’ ” Here, instead of worrying about how her hair or uniform looks, she says, “we just come as we come. It gives us that freedom.”

Some gender-equality advocates are skeptical about the trend. They question the creation of single-sex public schools because the approach hasn’t been proved to improve outcomes, and they worry it risks perpetuating gender stereotypes. With limited resources for strengthening education, they say, why not put more effort into closing STEM gaps within coed settings?

Still, the trend appears to be growing:

When the first TYWLS opened in East Harlem in 1996, it was the first all-girls public school started in the United States in 30 years. Now the network estimates there are about 100 district-run girls’ schools and 75 all-girls charter schools. It’s not known how many emphasize STEM.

The Hawthorn Leadership School for Girls, in St. Louis, opened this semester as the first single-sex public school in Missouri. The charter school will serve Grades 6 through 12, and students take two periods of math and a science lab every day.

In the fall of 2016, both Ohio and North Carolina will have their first all-girls public schools, also charters with a STEM focus. Los Angeles will open a similar school, run by the district.

Examples can be found in several cities in Texas; Baltimore; St. Paul, Minn.; and a number of other cities.

“There’s a lot more to our model than just the single sex,” says Laura Rebell Gross, director of the girls’ education program at the Young Women’s Leadership Network, which supports the New York schools and some affiliates around the country. “I don’t know if I can always separate the all-girls [aspect] from the college-going culture,... the smaller classroom..., and the advisory class we have every day [that is] focused on the social-emotional needs of the students. There’s just such a sense of community, and the girls’ voices are so strong.”

The results so far at the five New York schools are a source of pride for the network.

The graduation rate between 2005 and 2014 averaged about 95 percent, compared with 65 percent for all girls in the New York district. The students significantly outscored their citywide counterparts in math. More of the graduates are also going on to earn four-year college degrees.

The network is planning a study to determine the degree to which alumni – many of them first-generation college students – have chosen STEM majors and careers. Based on anecdotal evidence so far, “I truly believe as we continue to see them graduate from college ... we will see those results,” Ms. Gross says.

For now, according to the group Million Women Mentors, women earn only about 12 percent of computer science degrees – Geraldine’s hoped-for major.

Working on apps for ‘Tech Crew’

At TYWLS of Astoria, girls are clustered around laptops at two long tables, working on videos and apps in an elective called Tech Crew. Senior Brittany Greve is one of the “project managers” overseeing the class, while teacher Andrea Chaves coaches from the sidelines.

Brittany says she was more into English and history until this summer, when she took a course on coding at Harvard. There, she felt well prepared to take on leadership roles. “I wasn’t going to just sit back and let the guys do it.... A lot of the girls asked, ‘Why are you so comfortable?’ and I explained, ‘I go to an all-girls school,’ and that just confused them even more.”

They got it when she told them how supportive her teachers are and how much technology is integrated into the classes. “I feel like if I weren’t in this school, I never would have tried it at all,” she says. “Now I am venturing into the STEM fields, and I’m loving every minute of it.”

Ms. Chaves is the Spanish teacher who first introduced coding to the students, and has since helped many girls – and teachers – become enamored with computer technology. She has a master’s degree in integrating technology into education, and she recently partnered with a BuzzFeed volunteer who is helping to develop and teach a computer science class for any interested student at the school between Grades 9 and 12.

Coding has become so popular that teams who meet after school have won awards from the Massachusetts Institute of Technology, the Hispanic Heritage Foundation, and the Entertainment Software Association.

Chaves says the all-girls setting is powerful. In her previous teaching experience in coed schools, she says, when group projects included some aspect of technology, typically the girls would say, “He knows better how to do this. I will do the writing part and he will do the technology part.”

Federal criteria for single-sex schools

Under guidelines for Title IX, the federal gender-equity law in education, school districts can set up single-sex schools or programs, as long as they follow some criteria, such as ensuring that participation is voluntary and that the opposite sex has equal opportunities.

The American Civil Liberties Union (ACLU) has criticized and, in some cases, challenged the legality of some single-sex programs. Often, districts don’t offer enough justification for why such programs are necessary, which they should do to satisfy the equal protection clause of the Constitution, says Galen Sherwin, a senior staff attorney at the ACLU Women’s Rights Project in New York.

“The government has to try other things before resorting to sex separation, and show they can’t achieve their goals in coed settings. Many girls are able to succeed in science and math in coed schools,” Ms. Sherwin says.

She agrees that policymakers intend well and want to offer girls choices, but she also thinks backers of all-girls schools have overstated their impact.

The American Psychological Association published an analysis of 184 studies from 21 countries, conducted between 1968 and 2013. “The theoretical approach termed ‘girl power’ argues that girls lag behind boys in some subjects in coed classrooms,” said coauthor Erin Pahlke of Whitman College, in an article by APA. “This is not supported by our analysis and, moreover, girls’ educational aspirations were not higher in single-sex schools.”

However, the authors noted that there were few studies on single-sex education for low-income students and minorities in the US, although the studies that do exist have found positive effects for this population. This is the population commonly served by the recent wave of public STEM schools for girls.

“We’re not against public single-sex education per se, but ... it’s been our experience historically that separate education has not necessarily meant equal education, so we need to be very careful ... before we jump to single-sex as a solution to gender achievement gaps,” says Erin Prangley, associate director of government relations for the American Association of University Women (AAUW) in Washington.

Resources instead “could be spent on professional development for teachers ... about implicit bias in the classroom ... or computer science classes ... or developing extracurricular programs that encourage girls to develop their [STEM] skills outside the classroom,” Ms. Prangley says.

A 2008 study, for instance, found positive results from an outreach project that educated high-achieving minority girls about how scientists and engineers contribute to society. The high-schoolers knew little about engineering at the start of the study, but of the 66 percent who could be reached two years later, 8 out of 10 were seriously considering a career in engineering, AAUW reports.

For charter schools that focus on STEM, students generally have to apply as part of a lottery to get in, so the population may tilt toward boys if efforts aren’t made to reach out and show more girls the appeal of what’s being offered.

The first of the High Tech High network of public STEM charter schools, based in San Diego, had about 60 percent boys when it started in 2000.

To remedy that, “we had students who were female ... go into their [former] middle schools and show work that they were doing, and things they were building and making. The signal was, ‘This could be you if you decide to apply to this school,’ ”says High Tech High’s CEO, Larry Rosenstock. “Now we are pretty well balanced ... across the board.”

Back at TYWLS of Astoria, many girls wear navy-blue T-shirts that declare on the back, “Girls Rule!” When wearing the shirts in the community, “You can see the difference between what women say about the shirt and what men say about it,” says ninth-grader Sheira Medrano, referring to the skeptical comments they’ve gotten from some boys.

Sheira has paired with 12th-grader Noran Omar to work on a journalism project for the Tech Crew class, to spread the word about girls’ and women’s issues. “I am trying to send out the message that there is a gap [in STEM]. Girls in other schools are not really seeing it,” Noran says.

She hopes to share what she’s learned here: “You should follow your passion no matter what obstacle comes your way.”