I guess I am in a good position to answer this question, since I am in my mid-40s (almost), and — as Christopher Burke has mentioned in another answer to the same question — ageism does exist, but then it’s nothing but pure economics that drives it. And I also agree with him that after a while your salary hits a ceiling: there’s only so much that any company will pay a code craftsman. Look at this way, which is the better option of the two from the company’s perspective: hiring a senior developer and paying him a fat salary, or hiring two or even three much younger software developers and paying them the same amount and getting the job done? Of course, in the latter case the code may not be as good (experience and maturity matter), but then if weighted against the bang for the buck, it balances out.
On the other hand, from the software engineer’s perspective (or from mine, at least), one does tend to get bored writing software for others after a period of time. Software development is essentially a creative process, and writing code within the confines of specs thought up by somebody else, tends to get tiresome after some time. Like I would joke with my friends (careful! gets a little off-color here): writing great code is like great sex, you perform best when you do it for passion rather than for money.
So how do you handle this situation?
I love writing code, and I did realize back in my mid-30s that there was only so much I could expect in terms of salary growth after a while. And forsaking writing code and getting into management was not my cup of tea. So I knew that I was well on my way to hitting this supposed glass ceiling, and ergo decided back then to spin off in a different direction as a consultant. I tried this a bit but then things did not really work out well enough for me, but then I discovered yet another talent I had: writing. I ventured into writing and found a fair amount of success, and now am back in a job in a very well-known software company, but this time as a writer.
You see, I have an amalgamation of two very vital skills: writing code and writing prose, which lends itself very well to writing technical documentation. I have carved a nice niche for myself with a blend of two distinct, and perhaps even orthogonal, skill sets. This suits me fine too, since frankly, I had also grown quite weary of writing code for others. Not that I don’t write code now; I still do (it’s my primary skill, after all), but now it’s for my own self, and for my own joy.
My recommendation to senior software developers would therefore be to find another skill that they may have, which has been lying dormant all these years, and then try and figure out a way to combine it with your software development skills in a way that the market place will value.