Programming requires deep thought and concentration. Are you sure the issue isn't simple distraction? I'm 62 and I feel like the major thing that has changed in 35 years for me is the crazy amount of unrelated things (youtube, HN, phone notifications, you name it) constantly competing for my attention. When I was in my 20's I would literally sit in near-silence working for 10-12 hours at a time. Nothing would interrupt or distract me. Of course the Internet has also tremendously empowered engineers by putting a wealth of information at our fingertips, so it's a prototypical dual-edged bladed weapon.