I'm not yet 50, I'm "only" in my mid-40s, but for sure advancing in age has had an effect on the way I program code. For sure I won't be able to spend long hours in the night trying to decipher/solve a specific programming problem, I used to do that when I was younger.
I also used to type a lot more code, as in, my fingers used to type a lot more, I can't physically afford to do that now because after a certain threshold I can feel it in my fingers, and that feeling is not good.
I'd say that even my capability to stay focused on a specific issue has kind of changed, but maybe that's just a me thing, related to my specific life choices/environment, I couldn't tell, maybe some other programmers who have the same age as I do are better at keeping focused, or at least as good as they were 15-20 years ago.
I think I write much less code now to solve a given problem, largely due to a few decades of YAGNI experience. Gee, I could build this infinitely flexible inner system to solve this whole class of problems, or I could just write some code to concretely solve today’s problem, and keep it loosely coupled enough that we can replace it wholesale later if we need to.
That, plus a healthy dose of “good enough”, along with a whole lot of “I’ve written this 5 times already” lets me get easily maintainable stuff out the door more quickly than when I started.
If I were hiring, I’d vastly prefer current me to younger me.
It really varies by person and circumstances, and there's also things you can do (analogous to when someone with aches starts lifting weights, and gets in the best shape of their life).
Late nights are often a bad idea anyway. Though I literally just finished a successful all-nighter about an hour ago, I try not to make a habit of it. And there's a ton of things we know how to do, so that most all-nighters never need to happen.
Regarding typing, it might not be a "this is my life now" thing you just have to accept and work with, but there might be some practice/nuance or environmental factor that you can change for big wins. You can look into typing/workstation ergonomics, and experiment with the many variables, to see what works for you. I had to do that in my late teens, when most of our development team on a stressful project developed hand pain and worse, and learned what worked for me. Now I can type all day and night without problem. Having that known-good baseline means that I soon know when I start doing something that doesn't work for me. (Last time was a few years ago, when I started using a laptop with a numeric keypad at a startup, and hand started hurting. I think probably because hands had to twist badly for the way I was balancing the laptop with the off-center main keyboard. So I switched that work to a laptop without an off-center keyboard, and problem disappeared.)
Being only in my 30s but also affected by a lot of usually-age-related disability has been a big struggle for me as a programmer. I don't know how typical it actually is, but I guess I skipped the "work way too hard because your body can handle it" phase that appears to build reputation and wealth early in a career. Probably it would have been different if I'd grown up more physically active; I basically hate most sports and other ways of staying healthy and didn't learn their value until it started getting in the way of the things I do love.
Regardless, it's a massive toll on my mental health. Although frequently assured otherwise, I constantly feel like a burden on my team, like I'm unreliable, for being unable to put in the same hours my older coworkers do. As difficult as it is to start now, focusing on developing my physical health is the only way forward.
I'm the same age as you. I think it would be difficult to disentangle reduced focus from changed internet usage.
Personally I'm trying to watch less youtube. When I want a break from work, I try to go read a book for a while instead of taking the "mental junk food" option. I can't provide an objective report on whether measures like this help, but they do feel better.
I also used to type a lot more code, as in, my fingers used to type a lot more, I can't physically afford to do that now because after a certain threshold I can feel it in my fingers, and that feeling is not good.
I'd say that even my capability to stay focused on a specific issue has kind of changed, but maybe that's just a me thing, related to my specific life choices/environment, I couldn't tell, maybe some other programmers who have the same age as I do are better at keeping focused, or at least as good as they were 15-20 years ago.