If you're still an employee at 35-40 you have a job. If you think you messed up, ok, but if you think everyone who is an employee at that age messed up you've got unrealistic ideas. Not everyone wants to call themselves a founder. Retirement age in the US is 67-72, not 40. We're not all going to be Mark Zuckerberg or crypto billionaires.
The ability to remember and recall things degrades over time, but older people also have more experience to call on. And it happens to people at different times and rates. I sometimes have trouble recalling things from the past -- it actually feels like there's too much to search through. I don't have problems with short-term memory or getting my work done. I have learned over time how to organize my work, take notes, keep track of things, look things up, and ask other people for help.
There's no inherent reason older people are "going to be out of touch with young people." Differences in fashion and music and so on are superficial. I could just as easily say young people are out of touch with (and often dismissive) of their elders, who have more experience. Who is going to teach and mentor the young people if not us older people?
Most of us experience more health problems as we age. On the other hand young people have more car accidents, have more drinking and drug problems. Some of that gets reflected in higher car insurance rates for younger people (especially men), and unmarried people, because of actuarial statistics.
https://www.iii.org/fact-statistic/facts-statistics-teen-dri...
https://drugabusestatistics.org
Thanks to modern medicine people live longer and healthier lives. My own life expectancy today is significantly higher than it was when I was born.
Osteoarthritis is not just a disease of old age. Obesity, sedentary lifestyle, and injuries can cause it as well. I've been typing for 40+ years with no carpal tunnel or arthritis. I don't type eight hours a day anymore because my experience as a software developer taught me a few decades ago that typing eight hours a day is less effective than thinking and researching and planning so I only have to type for an hour or two a day. I have also long since mastered the tools of programming, so I'm doing a lot less typing today than when I was in my 20s.
The last time I worked with someone who suffered from carpal tunnel it was a guy in his early 30s. He hurt his wrists gaming, an affliction of the young in my experience.
What statistics inform you that older people are less likely to change their mind on any subject? Young people can be just as sure they're right, with the added problem of not knowing when they're wrong. If failing memory is a problem of the old, the Dunning-Kruger effect is a problem of the young.
What IBM did is almost certainly against the law. If they let someone go because they simply can't do their job because of physical or mental health reasons, that's probably justifiable. But to push older people out because they cost more and aren't willing to work twelve hours a day for pizza and beer, so they can exploit young people with less experience and fewer family/social commitments is simply wrong. If you are OK with an employer exploiting young people and getting rid of the more experienced people who could mentor and guide a career and know how to push back against companies that discriminate, good luck with that.
Age comes for all of us. At some point you realize you aren't all that special and don't know as much as you think you do, and grow some humility and respect for other people. That takes time. And when you get there you will probably react to stories like IBM's layoffs, and posts like yours, the same way I react at my age.