SEATTLE -- Leandre Nsabi, a senior at Rainier Beach High School here, received some bluntly practical advice from an instructor recently.
"My teacher said there's a lot of money to be made in computer science," Leandre said. "It could be really helpful in the future."
That teacher, Steven Edouard, knows a few things about the subject. When he is not volunteering as a computer science instructor four days a week, Mr. Edouard works at Microsoft. He is one of 110 engineers from high-tech companies who are part of a Microsoft program aimed at getting high school students hooked on computer science, so they go on to pursue careers in the field.
In doing so, Microsoft is taking an unusual approach to tackling a shortage of computer science graduates -- one of the most serious issues facing the technology industry, and a broader challenge for the nation's economy.
There are likely to be 150,000 computing jobs opening up each year through 2020, according to an analysis of federal forecasts by the Association for Computing Machinery, a professional society for computing researchers. But despite the hoopla around start-up celebrities like Mark Zuckerberg of Facebook, fewer than 14,000 American students received undergraduate degrees in computer science last year, the Computing Research Association estimates. And the wider job market remains weak.
"People can't get jobs, and we have jobs that can't be filled," Brad Smith, Microsoft's general counsel who oversees its philanthropic efforts, said in a recent interview.
Big technology companies have complained for years about a dearth of technical talent, a problem they have tried to solve by lobbying for looser immigration rules to accommodate more foreign engineers and sponsoring tech competitions to encourage student interest in the industry. Google, for one, holds a programming summer camp for incoming ninth graders and underwrites an effort called CS4HS, in which high school teachers sharpen their computer science skills in workshops at local universities.
But Microsoft is sending its employees to the front lines, encouraging them to commit to teaching a high school computer science class for a full school year. Its engineers, who earn a small stipend for their classroom time, are in at least two hourlong classes a week and sometimes as many as five. Schools arrange the classes for first thing in the day to avoid interfering with the schedules of the engineers, who often do not arrive at Microsoft until the late morning.
The program started as a grass-roots effort by Kevin Wang, a Microsoft engineer with a master's degree in education from Harvard.
In 2009, he began volunteering as a computer science teacher at a Seattle public high school on his way to work. After executives at Microsoft caught wind of what he was doing, they put financial support behind the effort -- which is known as Technology Education and Literacy in Schools, or Teals -- and let Mr. Wang run it full time.
The program is now in 22 schools in the Seattle area and has expanded to more than a dozen other schools in Washington, Utah, North Dakota, California and other states this academic year. Microsoft wants other big technology companies to back the effort so it can broaden the number of outside engineers involved.
This year, only 19 of the 110 teachers in the program are not Microsoft employees. In some cases, the program has thrown together volunteers from companies that spend a lot of their time beating each other up in the marketplace.
"I think education and bringing more people into the field is something all technology companies agree on," said Alyssa Caulley, a Google software engineer, who, along with a Microsoft volunteer, is teaching a computer science class at Woodside High School in Woodside, Calif.
While computer science can be an intimidating subject, Microsoft has sought to connect it to the technologies most students use in their everyday lives. At Rainier Beach High recently, Peli de Halleux, a Microsoft software engineer, taught a class on making software for mobile phones.
The students buried their faces in the phones, supplied by Microsoft. They were asked to create programs that performed simple functions, like playing a random song when the phones were shaken.
Leandre, who took Mr. de Halleux's mobile programming class last year and is in Mr. Edouard's Advanced Placement computer science class this year, proudly showed off a simple game he had created, Sun Collector, in which players tilt the phone to dodge black balls and hit big yellow ones.
"I never really understood what was behind these games," he said. "Once you start getting it, it's pretty easy to understand."
One of the most alarming trends for the technology industry has been students' declining interest in computer science over the last decade.
While the number of undergraduate degrees granted in computer science has been growing for the last several years, last year's figure was still 34 percent lower than at its peak in 2004, according to the Computing Research Association.
Student interest in the field began to fade after the dot-com implosion a decade ago. It has picked up again in recent years, but slowly.
Most educators believe that for students to be excited about computer science, it is critical to introduce them to it at an early age. Yet support for the subject at cash-short K-12 schools has faded. In almost every state, computer science is taught as an elective, rather than a core requirement.
The percentage of graduates who earned credits in high school computer science classes fell to 19 percent in 2009 from 25 percent in 1990, making it the only subject among science, technology, engineering and mathematics courses to experience such a drop, according to a report by the Education Department.
Those numbers are all the more surprising considering how attached teenagers are to their smartphones, tablet computers and Facebook accounts. But that fascination in most cases is with social communications and media, rather than the technology itself. Today's easy-to-use gadgets have also concealed programming tools from users that were once far more prominent in computers.
Finding capable computer science teachers is also hard. Few other industries are as good as the technology business in its ability to divert would-be educators into far more lucrative corporate jobs. Mr. Edouard graduated from the University of Florida in 2011 and considered enlisting in Teach for America, but he also had multiple offers from technology employers.
"In today's day and age, with so many college loans, it's tough to go into teaching," he said.
One of the biggest concerns about Microsoft's effort is that most of its volunteers have little teaching experience. To comply with district licensing requirements and to help engineers with classroom challenges like managing unruly teenagers, a professional teacher is also in the room during lessons. One of the program's tenets is that Microsoft engineers need to teach the teachers, alongside students, so that those instructors can eventually run an engaging computer science class on their own.
"We are taking the kids farther than I could do," said Michael Braun, a teacher at Rainier Beach High who is working with Microsoft volunteers.
There are still hiccups, including tensions between some of the professional teachers and the Microsoft engineers assigned to work with them, according to several people involved in the program, who did not want to be named for fear of seeming critical of Microsoft.
Sarah Filman, a program manager at Microsoft, completed the intensive summer training that the company offers volunteers, preparing a lengthy PowerPoint presentation for the class she taught at a Seattle high school last year. "That's the Microsoft way," she said.
But as soon as she dimmed the lights in her classroom at the start of the year, her students had trouble focusing on the slide show, forcing Ms. Filman to change her methods. "I had to throw away a lot of what I had done," she said.
For students in the Seattle area, Microsoft tries to drum up excitement in technology by organizing field trips to its campus and discussing the lucrative careers that await them. The students from Rainier Beach High who visited Microsoft last year were buzzing about their trips for days afterward.
"To me, that was an 'aha' moment," said Dwane Chappelle, the principal of Rainier Beach High. "I said, we've got to find a way to get more kids involved."
Mr. Wang, the program's founder, said a professional from the tech industry who stands at the head of a class for a full year can be a powerful role model. "Kids can see themselves in their shoes," Mr. Wang said. After all, he added, "their chances of going to college and majoring in computer science are exponentially better than getting into the N.F.L."
This article originally appeared in The New York Times.