Lieutenant Christopher Billiau was 5 months and 19 days from having his retirement and pension secured when he “involuntarily separated” from the military—code for being fired—in a round of cost-saving cuts.

“The military was who I was, and then one day it wasn’t,” Billiau, 43, said after nearly two decades in the Coast Guard and the Navy. “The rug was really pulled from under me, and reality rushed in fast and hard. You have all these plans to do something vaguely cool and interesting when you are approaching retirement, and the timetable was suddenly sped up.”

He bounced between a few jobs he hated for a few years to help support his wife and three children. But after spending a career driving ships in the East Atlantic, working on drug interdiction in South America, and generally traversing the globe, he realized that corporate culture bored him to death. That’s when he decided to take the plunge into something that wouldn’t: learning JavaScript.

He’s one of a growing number of middle-aged Americans dipping into their savings, borrowing money and even refinancing their homes to reinvent themselves by attending the growing number of coding boot camps sprinkled across America. The camps offer intensive courses in web development, usually lasting three to six months. More often than, attendees quit their day jobs to attend.

“It’s a sacrifice, but I have a lot of working years left, and I don’t want to spend it doing something I hate or that isn’t relevant,” said Billiau, who attends a course run by Thinkful in Connecticut.

The boot camp boasts a 92 percent job placement, and graduates see their salaries increase by 106 percent on average.

“Coding is a job of the future, and I still have a lot of future left,” Billiau said.

The demand for software engineers is growing fast, with the number of jobs in the profession expected to grow by of 18.8 percent by 2024, nearly triple the rate of overall job growth, according to the Bureau of Labor Statistics.

While the U.S. unemployment rate in May was 4.7%, according to the Bureau of Labor Statistics, the rate for programmers was nearly a quarter of that at 1.3 percent. Computer science majors can potentially earn 40 percent more than the average college graduate over the course of a lifetime, according to the Bureau of Labor Statistics. Software engineers earn a median salary of $74,280, and computer science majors stand to earn 40 percent more than the average college graduate over the course of his or her lifetime.

Given those stats, it’s easy to see why a cadre of people in their 40s and 50s who have either grown tired of their current careers or been forced to leave them see coding as the way to job security. There’s also the appeal of the job itself: Although the very term “coding” evokes an image of tedium, it is an intellectually challenging activity, creative and even artistic. You not only get to solve puzzles for a living, but also compose them.

Last year, more than 16,000 students graduated from coding boot camps, a 138 percent increase from the year before, according to Course Report, an organization that tracks the industry.

To date, however, age hasn’t been seen as a virtue in the field. When a company called PayScale recently surveyed the country’s 32 most successful tech companies, it found that just six of them had a median age over 35. (The median age at Facebook, Google, Zynga, AOL, and Zynga was 30 years or younger.) By contrast, the median age for all workers in the U.S. economy is 42 years.

“Young people are just smarter,” Facebook CEO Mark Zuckerberg famously told an audience at Stanford back in 2007, an example of how Silicon Valley, and the tech industry have lionized youth.

The preference for fresh-faced tech workers has prompted older people to adjust in surprising ways. Serial entrepreneur Randy Adams, 60, who was involved in the founding of Yahoo, Inc. and FunnyOrDie, chose to get an eyelid lift and don a pair of Converse to a job interview after being turned down over and over for CEO roles. Only then did he get the job.

“The age thing is scary,” said Martha Rogers, 48, who signed up for DevBootCamp in San Diego after 20 years working in various capacities in the geographic information systems field.

She tries not to think about it, however, hoping that her management experience, people skills and industry knowledge will help her get a job at a startup, or maybe start her own business when she is done with camp in a few months. The path she is taking is not for the meek, but pursuing further training to stay relevant in a quickly changing economy is going to be an important step for more and more workers in the future.

“Not working for months is scary,” Rogers said of her training experience. “Spending the money for the classes is scary, and the hours of work every week can be scary too. But you have to be a risk-taker or it won’t work. You have to believe it will all be worth it in the end.”