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.
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.