At about 40, it does start to get more difficult to get hired. And by 50, it is all but hopeless. And the salary offered begins to go down at 40 too. Sharply after 44 or so. Where I am now, at 51, I have had to learn to get by on what I was making as a SysAdmin 20 mumble years ago. But at least I have a job. Before getting my current job I was having to learn to get by without a place to live too.
Note that it's all based on perceived value, which is only partly based on actual value, which is only partly based on skill. I'm not trying to brag or put anyone down here. A lot of it has to do with what I said in another comment about specialization. Nobody wants to pay a thirty-year veteran's salary for a job where they don't already have deep expertise. People who can find jobs closely aligned with their skills and specialties often continue to do OK. People who can't - and it's usually more to do with shifts in the market than in them - get left out.
The sad fact is that many older programmers' skills and instincts often do apply outside their area of obvious expertise. Recognizing code smells or knowing how to test code properly are valuable skills in any specialty. So is communication, or scheduling, or being able to recognize and mentor up-and-coming young developers. Most older programmers - not just the few lucky ones - are well able to justify their salaries but never get the chance. That's a "soft" kind of ageism, but it's ageism nonetheless.