From what I've read, experienced, and observed, it would seem novelty is the crucial element in preserving and, even heightening, mental acuteness. Whether you are a programmer or a chess player; that alone might not be sufficient--you should always pursue novel activities. I tend to suggest music theory and learning to play an instrument.
Programming and software development need not be complex, and indeed a lot of programmers do not work on complex things, much of what they do is just routine, and that will not be enough stimuli for your brain.
I think continuously becoming a better programmer is probably a good way to go at this. If you can sprinkle in some traveling and learning another language or to while you're at it, that would perfect. And maybe learn a musical instrument as well.
Just went on a trip with my recently retired father.
The effect of a total change of routine, new experiences and challenges, emotional experiences (stress, wonder, happiness), was huge.
It was the first time I saw him look alive in months.
In retirement, I think you cam get stuck in am easy, comfortable rut. As in working age life but more so. Travel to novel places, with novel people, doing novel things, can force you out of that rut. Probably worth remembering for younger rutters as well.
There is so much novelty one encounters when traveling, on multiple levels. I definitely recommend everyone to travel and visit new places as much/often as possible, even in their own country.
Of course, I'm not talking about candy tripping in Ibiza.
Programming and software development need not be complex, and indeed a lot of programmers do not work on complex things, much of what they do is just routine, and that will not be enough stimuli for your brain.