In what looks like a small startup office in a New York financial-district building earlier this year, a roomful of teenagers examined lines of code projected on to a classroom wall. The code made up Beyonce’s Twitter page, and the teens were figuring out how to collect and organize it.

These high-school students gave up four hours each Saturday for three months this past winter to learn how to build web apps at the Flatiron School. Their parents shelled out $2,500 for 12 weeks of lessons. There’s a shortage of coders in the United States, and schools like this are trying to be the solution.

Information technology was one of the science, technology, engineering, and math (STEM) fields with the most job postings in the U.S. in 2013, and job postings requiring coding skills stayed open longer than most. A national non-STEM job opening is filled in about 33 days, compared to 56 days for jobs that require programming skills and 65 days for mobile developing, according to Matt Sigelman, CEO of the career analytics firm Burning Glass.

Ian Aberbach and Sydney Steiner, high school students learning web development at the Flatiron School. (Sonali Kohli)

Simply put, there would be more people to fill these jobs if there were more computer-science graduates, and there’d be more graduates if more people could start the subject in high school. And yet it’s difficult to find a high-quality computer science class in American high schools, let alone a programming one.

Hence the demand for places like the Flatiron School. It works for teens who already know they want to learn programming, or those who have parents nudging them toward it. But the problem with relying on schools like this is the assumption that people who want to code will seek it out and have the money to pay for lessons.

There are many reasons why American schools are poor at teaching coding—so many that the Computer Science Teachers Association (CSTA) published a 75-page report enumerating them. The biggest issue is that the public-school system is decentralized. Most public schools follow national teaching guidelines—the Common Core—and complete standardized tests based on those, but states and local bodies make classroom-level decisions.

Computer science also has a hard time finding a place in schools because it can fall under pretty much any letter of the “STEM” acronym. Some states classify computer science as its own subject, while others lump it into math or science. A Kentucky lawmaker even tried to have programming languages treated as foreign languages.

These umbrella designations influence how the subject is taught. In a 2014 CSTA survey, schools included topics like web development and learning Excel in computer-science classes. Real computer science, the kind tech companies need, is a more rigorous discipline that teaches students to break problem-solving into small chunks.

There have been attempts to standardize computer-science teaching. The CSTA suggests ways to incorporate it into national math standards, and a bill is currently inching its way through Congress to make the subject part of the government’s definition of STEM. That would allow computer-science programs to more easily apply for federal STEM funding.

Yet even if a school district properly identifies computer science or programming classes, more obstacles abound. Schools might not have room in the schedule, or funding, for an additional course. Since computer-science classes are often optional electives, students may choose easier subjects instead. Or—the most basic problem—a school in a poor district may not have enough computers or Internet access to teach a course.

The lack of classes isn’t the only reason for the shortage of computer-science graduates. Another is that the profession is so homogenous. Women and people of color don’t see many of their older counterparts succeeding in it, so they’re less likely to pursue it. For example, girls consistently receive messages—both implicit and explicit—that science and math aren’t for them. Recent research suggests that more women would graduate college with math and science degrees if their middle and high schools employed more women to teach those subjects.

“I think for girls one of the things that’s very important is that they see that the expectation is that they can do it,” said Jane Foley Fried, the head of the private all-girls Brearley School in New York. That’s why she introduced coding classes as electives into the curriculum.

But Brearley is private and doesn’t answer to an education board. Not all schools have its funding and flexibility. Employers and nonprofits recognize this, and are trying to help. Flatiron said in January that about 20 percent of its students attend on a scholarship through partnerships with nonprofits.

Outfits like and Black Girls Code help, as do some employers: Google’s Made with Code aims to bring women into the field, while payments company Square offers high-school code camps. Intel just last week pledged $5 million for computer-science programs at two high schools in Oakland, California.

“If [employers] don’t help nurture this group of students coming through school now, they’re not going to have future employees,” said Deborah Seehorn, the chair of the board of the CSTA and an education consultant for the state of North Carolina.

Apparently, teaching kids computer science looks, to venture capitalists, like a business idea as good as any tech startup. A month ago the Flatiron School completed a $9 million fundraising round, and says it is expanding its high-school courses beyond New York, into individual schools in other cities including Los Angeles and Miami. Still, scholarships for schools like Flatiron, and nonprofit programs like Black Girls Code, can only help a limited number of students.

There are a few attempts to do coding classes at scale. Flatiron is partnering this summer with Teach for America, which places teachers in low-income schools. The goal is to train teachers who have at least two years of experience in another subject to code, and to provide lesson plans so that they can then take the education back to their schools.

The Starter League, a Chicago company offering bootcamps similar to Flatiron, partnered with the city’s public-school system. It trained teachers in web development, then provided support as the teachers added those skills to their own computer -cience classes, said Arjun Venkataswamy, the director of partnerships at the Starter League.

The city’s goal is to make computer science part of the core curriculum for the whole city, said Brenda Wilkerson, who heads computer-science and IT education for Chicago’s public schools. That’s different from the Flatiron and Teach for America model, which leaves teachers in low-income areas to navigate the educational system themselves. It helps that Wilkerson is an engineer by training, and understands the need for more equal opportunity from personal experience. “When I was in engineering school I was the only woman, I was the only black woman,” she said. “Our goal has been to democratize computer science across the district.”

It’s true that high-school classes aren’t essential for learning computer science in college. Students without experience can catch up after a few introductory courses, said Tom Cortina, the assistant dean at Carnegie Mellon’s School of Computer Science.

However, Cortina said, early exposure is beneficial. When younger kids learn computer science, they learn that it’s not just a confusing, endless string of letters and numbers—but a tool to build apps, or create artwork, or test hypotheses. It’s not as hard for them to transform their thought processes as it is for older students. Breaking down problems into bite-sized chunks and using code to solve them becomes normal. Giving more children this training could increase the number of people interested in the field and help fill the jobs gap, Cortina said.

Students also benefit from learning something about coding before they get to college, where introductory computer-science classes are packed to the brim, which can drive the less-experienced or -determined students away. At least one college is trying to combat that, keeping women in the department by placing the the best professors in the introductory classes.

Flatiron started as one of the many coding bootcamps that’s become popular for adults looking for a career change. The high-schoolers get the same curriculum, but “we try to gear lessons toward things they’re interested in,” said Victoria Friedman, an instructor.

For instance, the students learned to read HTML by messing with Justin Bieber’s Twitter feed—looking at the code that makes up his tweets and changing it on their own computers so that it looked like he had tweeted something different. One of the apps the students were developing on the day I visited suggests movies based on your mood. Another app emails the user a daily roundup of how their favorite sports teams performed.

Some of the students were having trouble getting information from the databases for different projects—movies and their genres from movie site IMDB, for example. That’s where Beyonce and her Twitter account came in, as Friedman used the code behind the singer’s tweets to teach the students how to search for a certain topic and harvest that data.

“It’s OK if this feels hard and random,” Friedman said to the class. “It is kind of hard and random.”

The students in the Flatiron class probably won’t drop out of high school and build the next Facebook. Programming languages have a quick turnover, so the “Ruby on Rails” language they learned may not even be relevant by the time they enter the job market. But the skills they learn—how to think logically through a problem and organize the results—apply to any coding language, Seehorn said.

Indeed, the Flatiron students might not go into IT at all. Emma Ladouceur, who was 15 at the time of the course, is a sophomore at the private Brearley School; she was the one in the Flatiron class building an app to send personalized sports score roundups. Ladouceur wants to get a soccer scholarship for college, and maybe, she said, study computer science.

But creating a future army of coders is not the sole purpose of the classes. These kids are going to be surrounded by computers—in their pockets, in their offices, in their homes—for the rest of their lives. The younger they learn how computers think, how to coax the machine into producing what they want—the earlier they learn that they have the power to do that—the better.