I am not sure age discrimination is as endemic as people believe. The real problem is that skills are perishable; any technical person needs to have a second job always, which is to remain current. Imo, staying in the same industry helps a technical person, by allowing him/her to accumulate domain knowledge. Domain knowledge is harder to acquire than technical knowledge.
Also working against older technical people is this: Managers feel threatened by older workers, and conspire to give them impossible-to-complete assignments, in the hope of removing them from the workforce. The solution, again imo, is to move away from larger organizations with formal management teams, and toward more entrepreneurial, smaller, newer, and often privately held companies. Once a person acquires sufficient expertise in a niche (a.k.a. specialized domain knowledge), this becomes less important.
Ten years ago, coders over 45 were much more vulnerable, because they tended to be more into older languages, like COBOL and C++, which were beginning to lose share in favor of Java and .NET.
But now, coders that age, tend to be fluent in Java and .NET, which are still going strong.