It's a little ironic to hear talk like this, since around here I hear a lot of "sorry your coal mining job is going away, but you need to get with the times and train for something relevant". Same thing applies here. If you pick a programming specialization that eventually falls out of favor, buck up and learn a new one. Maybe that'll mean a pay cut for a bit as you ramp up, but that's just how it works.
It's a different story, I guess, if you go into a completely different type of programming from what you're used to (say Web apps to embedded programming), but I don't think that's necessarily easy.
Important difference.
For example, at one extreme, all tech lasts exactly three years; at one of several other extremes, 50% of tech is eternal and the rest lasts exactly 1.5 years.
My philosophy is that if PHP keeps the lights on, I better really know what it is, where it's going, what are it's limitations, because it would be pretty scary not to.
Plus once you learn a language or a database well, the next one is easier. The trick is knowing when it's time for the next one.
Don't mistake what I'm saying. I'm using the word "own" rhetorically. Obviously there will be no point in your career where you are likely to be the world's leading expert on computer vision. What you're aiming for is to be the leading expert that is available to employers within a reasonable amount of time at the level of compensation you're hoping for.
It's a spectrum.
Obviously, if you invest heavily in a discipline and it is decisively obsoleted, that's a setback. I'm just saying it's not an insurmountable setback, and I'll add here that it's still unlikely to leave you behind the pure generalists; in the process of building expertise and accomplishment in cryptography or OS kernels or whatever, you're likely to become a pretty far above-average software developer as well.
But the few people who are really hiring people who "own" CV want PHDs with a relevant thesis and you're not going to get one of those working weeknights after the kids go to bed.
Meanwhile people pursuing PHDs have no idea if their area of research is going to be hot in industry when they're done.
Granted, a lucky few people who follow the autodidactical route may find themselves authors of a really popular OSS project. Or they may be able to luck or maneuver themselves into a position at their current employer working in a capacity that future employers will see as "relevant industry experience." Obviously this is hardly a sure thing and if they plan it wrong or just get unlucky they're not going to have a nice outcome.
As a counterexample, though, most serious work in cryptography (for instance) is done by grad students, but the best jobs in crypto are not automatically going to grad students.
Either way: if your goal is to maximize lifetime earnings, I think dedicating your career to "programming" is a bad call.
My point isn't that becoming a subject matter expert isn't a good way to supercharge your earnings for a few years. I agree with you there.
Clearly, a guy with lots of experience with and deep knowledge of the Oracle database could do pretty well for himself 10 years ago. A person with lots of experience with and deep knowledge of OpenStack could do the same five years ago.
My point is that it's not a good, safe or stable way to ride out the last half of a 30+ year long career.
My further point is that demand for lots of these specialists doesn't appear to be particularly elastic, and therefore "become a subject matter expert" is not a universally applicable bit of career advice for every LOB engineer worried about ageism: if everyone successfully took your advice there would be a whole bunch of unemployed crypto experts.
It's not my claim that simply by moving to a specialized subfield of programming that you'll instantly quadruple your salary and future-proof your career.
Obviously, you're going to start in some domain speciality as a commoditized practitioner and, with effort, move yourself to more elite ranks of that subfield.
My point is that it is better to work on that problem --- of being an elite in a specific domain --- than it is to be an elite at the general problem of building reliable software.
(It's "Burp", by the way.)
A guy with lots of experience and deep knowledge of databases in general, though, would do pretty well for himself both 10 years ago, and today. Even better if he worked on some database himself. Really, that's what owning a domain means: you don't want 10 years of experience as a _user_ of some technology, you want that experience as a _builder_ of said technology.
Are you sure about that? I mean sure, if we're talking someone who wants a deep learning research project to improve the metric for recognizing human faces from 99.7% to 99.78%, then we're talking about PHDs.
But there are plenty of "simpler" problems that one can work on, and plenty of more engineering-oriented problems that one can work on. Lots of companies just need to apply semi-standard techniques to problems that are specific to their business, and nothing more complicated or research-y.
There are so, so many businesses out there that could benefit from CV, but they don't realize it. Maybe they're spending a ton of money on off the shelf OCR software that isn't great for their needs. Maybe they're spending a few hundred thousand dollars a year manually organizing and classifying documents when they could automate it.
These companies won't be hiring someone to own CV for them, because they don't know they need it. They might not even know what computer vision is. And they won't care about whether you have a PhD or a relevant thesis. They'll care about whether can can demonstrate that you can solve their problems and save them a pile on money.
Granted, finding companies with these types of problems is perhaps not something that a typical LOB programmer knows how to approach. And if they see themselves as just a LOB programmer, it might stay like this.
If they make an effort to get to know people and network outside of the usual tech circles, they might just find it possible to position themselves as solvers of specific types of problems - problems to which CV happens to be the best solution.
I know that's not a path that'll work for everyone. But it's one path that leads from 'LOB Programmer' to 'Someone who makes lots of money doing development with computer vision'.