I see relentless ageism as the result of the flood of new computer science talent. It biases recruiter expectations to seek out a certain type of candidate. Your experience as an older programmer is unique here and this could be an important opportunity for you to disrupt the status quo (eg. affect HR.)
Regarding lack of respect, I'm assuming you mean respect for the field of Computer Science? I think this is the result of the explosion in industry/applications of programming. Dollars drive attitudes, which has resulted in Ruby on Rails being the pinnacle of many programmers' fascination in computer science, as an example. Not that I dislike Ruby on Rails, of course!
I know it's ridiculous for someone half your age to give advice, but if you're worried about diminishing earning potential, ageism, and lack of respect, consider consulting. Your experience is directly valued and the earning ceiling is much much higher (if it exists at all). I know several 40+ year-old developers who have had tremendous success working as consultants and getting lots of respect from companies which otherwise exclusively employ 20-somethings.