Slide Show

WHEN Julia Geist was asked to draw a picture of a computer scientist last year, the 16-year-old sketched a businessman wearing glasses and a tie. Looking around at her classmates’ drawings, she saw similar depictions of men.

Now, Ms. Geist said, “I see a computer scientist could be anyone” — including herself.

Her new perspective is a victory for Girls Who Code. As part of an eight-week program with the Manhattan-based nonprofit group, Ms. Geist and 19 other high school girls learned software programming, public speaking, product development and other skills to prepare them for jobs in the technology industry.

Girls Who Code is among the recent crop of programs intended to close the gender gap in tech by intervening early, when young women are deciding what they want to study. With names like Hackbright Academy, Girl Develop It, Black Girls Code and Girls Teaching Girls to Code, these groups try to present a more exciting image of computer science.

The paucity of women in the tech industry has been well documented. Even though women represent more than half the overall work force, they hold less than a quarter of computing and technical jobs, according to the National Center for Women and Information Technology based at the University of Colorado, Boulder. At the executive and founder levels, women are even scarcer.

A variety of advocacy and networking groups have tried to address the problem by coaching women on building start-ups, raising venture capital and climbing the management ranks at big companies. Most recently, Sheryl Sandberg, the chief operating officer of Facebook, published a best-selling book, “Lean In,” that was a call to arms for women to pursue their ambition in the workplace.

Even so, the number of women entering technology has been declining. Women earn just 12 percent of computer science degrees, down from 37 percent in 1984. Tech executives, recruiters and financiers say women simply do not walk through their doors seeking work.

“We actively recruit women, but there’s just not that many women who want to do this kind of work and are equipped to do the work from their education,” said Adam Messinger, the chief technology officer at Twitter, who is on the board of Girls Who Code.

So the industry is trying a new approach. It is tackling the problem long before women start their careers, by teaching girls the basic skill of writing code.

“We have to get women on the right side of the computer,” said Margit Wennmachers, a partner at Andreessen Horowitz, a venture capital firm in Silicon Valley. Knowing a programming language is becoming essential not just for engineers, she added, but also for women who want to be tech executives or deal-makers or pursue other careers, from medicine to fashion.

“The dividing line is learning to code,” Ms. Wennmachers said. “You either tell the computer what to do and you’ve got lots of great career options. Or the computer tells you what to do and you end up working in a shoe store.”

Groups like Girls Who Code are part of a national movement to recruit young people to software development and remain competitive with other economies. A new group, code.org, for example, has people like Mark Zuckerberg of Facebook and Bill Gates of Microsoft pushing for all schools to teach children to code.

But the need is most urgent for girls, said Reshma Saujani, who founded Girls Who Code last year. Roughly 74 percent of girls in middle school express an interest in engineering, science and math, she said. But by the time they get to college, just 0.3 percent choose computer science as a major.

Ms. Saujani, the daughter of two engineers who were refugees from Uganda, developed the idea while she was running for Congress, a race that she lost. As she traveled from school to school on the campaign trail, she said she saw the same thing over and over: computer science classrooms without a single girl.

“I saw the ability of technology to either enhance poverty or reduce it, and I saw girls not getting the same opportunities boys were,” said Ms. Saujani, who is now campaigning for public advocate in New York City. “Back in the ’60s, you didn’t have gender parity in law or medicine, but something happened and women started opting into these professions. We have to do that in computer science.”

Researchers say many factors contribute to girls’ reluctance to pursue computing as early as elementary school, including discouraging parents, inadequate resources for teachers and a lack of exposure. Studies have shown that girls imagine computer scientists as men working alone in a basement and can’t relate.

It’s a significant disconnect, given how women embrace technology. Female consumers make up a majority of users for many tech products. For technology companies, women also offer a diverse perspective, which can help bolster the bottom line.

“Being a software developer gives you a lot of insight into the world and business and gives you a lot of career opportunities,” said Sara J. Chipps, the co-founder of Girl Develop It, and the chief technology officer of Levo League, a Web start-up for professional women.

After hatching the idea for Girls Who Code, Ms. Saujani and Kristen Titus, its executive director, started going to tech companies and asking what skills they wanted in female applicants. Mr. Messinger at Twitter, for instance, said he wanted to see more candidates who knew how to break a problem into parts and describe it in logic terms, which was incorporated into the program’s curriculum.

The response from companies was encouraging. The group raised money from Google, Twitter, Intel and other technology companies. Some also agreed to host workshops for Girls Who Code at their offices and volunteered employees to teach courses.

To develop the classes, the women recruited academics and people who worked in tech to design the curriculum, which includes topics like robotics, animation and mobile app development, as well as skills like introducing yourself in a business setting and presenting your product onstage. By Week 2, students learn what an algorithm is and how to write one to program a robot. By Week 5, they build their own mobile apps.

Then there are the intangibles, like eating in the Twitter cafeteria, pitching the apps the students built to Twitter’s engineering team and listening to notable female executives talk about what it was like to be the only girl in their computer science classes. Last year, so many girls said they wanted to become forensic scientists — as in the hit television show “C.S.I.” — that the group took a field trip to the New York Police Department to see how they used computers.

Nikita Rau, 17, another Girls Who Code graduate, said seeing female programmers on field trips taught her that anyone could be a coder. At big companies like Google and small ones like Foursquare, she said she was inspired by seeing successful women, and engineering problems scrawled on white boards — not to mention “the amazing food.”

“As we walked through Facebook and Twitter, I could imagine myself sitting there coding throughout the day,” she said. “I’m not afraid to be one of the first girls to go into one of those fields. I want to pursue this career and maybe be a C.E.O. of a company.”

Girls Who Code is still in its infancy. In 2012, it taught 20 girls in New York. This summer, the program will accept 160 girls in New York, San Francisco and Detroit. The group is packaging its curriculum so schools and community organizations can teach it, too.

Girls Who Code is already showing signs of progress.

In March, it hosted a recruiting event at Google’s New York office for 200 girls, parents and teachers. Last year’s graduates showed off the apps and Web sites they built and attendees were treated to Google’s famous perks, including a demo of its Internet-connected glasses and a spread of beef sliders and chicken fingers.

Ms. Geist, the high school student who had never taken a computer science course, built an app for finding people with similar interests on Twitter. Now, she has signed up for the only computing courses in her public high school and wants to study computer science and physics in college. She even persuaded her father, a part-time custodian, to take a programming class.

“I guess I was just doing what my friends were doing, and none of the girls wanted to do computer science because it was mostly just guys,” Ms. Geist said. “But I don’t really care about that now. I love computer science.”