Which of the following describes careers in software engineering?

A. Intellectually stimulating and gratifying.

B. Excellent pay for new bachelor’s degree grads.

C. A career dead-end.

The correct answer (with a “your mileage may vary” disclaimer) is: D. All of the above.

Although the very term “coding” evokes an image of tedium, it is an intellectually challenging activity, creative and even artistic. If you like puzzles and are good analytically, software development may be your cup of tea. You not only get to solve puzzles for a living, but in essence you compose them.

Wages for new computer-science graduates working as software engineers are at, or near, the top of most surveys, certainly compared with new humanities grads. We hear about the gap a lot this time of year, as students compare job offers.

You had better be good to get that first job in computer engineering, because you will probably be asked to code on command during job interviews; employers have been burned too often by those with high grades yet low ability. But those who are chosen are generally paid well and love the work.

The downside? Well, say you interview as a graduating college senior at Facebook Inc. You may find, to your initial delight, that the place looks just like a fun-loving dorm -- and the adults seem to be missing. But that is a sign of how the profession has devolved in recent years to one lacking in longevity. Many programmers find that their employability starts to decline at about age 35.

Gone by 40

Employers dismiss them as either lacking in up-to-date technical skills -- such as the latest programming-language fad -- or “not suitable for entry level.” In other words, either underqualified or overqualified. That doesn’t leave much, does it? Statistics show that most software developers are out of the field by age 40.

Employers have admitted this in unguarded moments. Craig Barrett, a former chief executive officer of Intel Corp., famously remarked that “the half-life of an engineer, software or hardware, is only a few years,” while Mark Zuckerberg of Facebook has blurted out that young programmers are superior.

Vivek Wadhwa, a former technology executive and now a business writer and Duke University researcher, wrote that in 2008 David Vaskevitch, then the chief technology officer at Microsoft Corp., “acknowledged that the vast majority of new Microsoft employees are young, but said that this is so because older workers tend to go into more senior jobs and there are fewer of those positions to begin with.”

More than a decade ago, Congress commissioned a National Research Council study of the age issue in the profession. The council found that it took 23.4 percent longer for the over-40 workers to find work after losing their jobs, and that they had to take an average pay cut of 13.7 percent on the new job.

Why do the employers prefer to hire the new or recent grads? Is it really because only they have the latest skill sets? That argument doesn’t jibe with the fact that young ones learned those modern skills from old guys like me. Instead, the problem is that the 35-year-old programmer has simply priced herself out of the market. As Wadhwa notes, even if the 45-year-old programmer making $120,000 has the right skills, “companies would rather hire the younger workers.”

Whether the employers’ policy is proper or not, this is the problem facing workers in the software profession. And it’s worsened by the H-1B work-visa program. Government data show that H-1B software engineers tend to be much younger than their American counterparts. Basically, when the employers run out of young Americans to hire, they turn to the young H-1Bs, bypassing the older Americans.

Fewer Managerial Jobs

With talent, street smarts and keen networking skills, you might still get good work in your 50s. Moving up to management is also a possibility, but as Microsoft’s Vaskevitch pointed out, these jobs are limited in number. Qualifications include being “verbally aggressive,” as one manager put it to me, and often a willingness to make late-night calls to those programmers in India you have offshored the work to.

Finally, those high programmer salaries are actually low, because the same talents (analytical and problem-solving ability, attention to detail) command much more money in other fields, such as law and finance. A large technology company might typically pay new law-school graduates and MBAs salaries and compensation approaching double what they give new master’s degree grads in computer science.

If you choose a software-engineering career, just keep in mind that you could end up working for one of those lowly humanities majors someday.

(Norman Matloff is a professor of computer science at the University of California, Davis. The opinions expressed are his own.)

Read more opinion online from Bloomberg View.

Today’s highlights: the View editors on the government’s case against book publishers and Romney’s critique of Obama’s Afghanistan policy; William Cohan on more missing MF Global money; Albert Hunt on key swing groups in the general election; Noah Feldman on Egypt’s bungled elections; Pankaj Mishra on Pakistan’s rising middle class; and Paul Fourier on Europe’s social safety net.

To contact the writer of this article: Norman Matloff at matloff@cs.ucdavis.edu.

To contact the editor responsible for this article: Katy Roberts at kroberts29@bloomberg.net.