Now in regards to life more broadly ... the big changes have mostly been around health & fitness. I was great up until about 42, and then things took a bit of a downward turn. I went from having no (known) chronic issues and mostly only needing the doctor for sports related injuries, to developing type 2 diabetes and eventually have two heart attacks. Luckily, despite all that I can still mountain bike, run, etc. but I'm definitely starting to notice that I don't have the energy I used to have. And now I'm on a pile of prescription drugs and see the doctor a lot more regularly.
The biggest thing I'd say to someone who is right around 40 is this: if you're in good shape physically and are active, KEEP IT UP. If you're not very fit and aren't active physically, please for the love of FSM, find a way to get active and get fit. And when you do get there, don't stop. That was always one of my problems throughout my life: I'd go through "phases" that would alternate between me training for competitive sports and focusing on fitness to an obsessive degree, and periods where I was a complete slob / couch potato. Too many of the latter are, I strongly believe, a big part of why I saw the health decline I did.
I hate to be the preachy type, but please take this to heart. Adopt a healthy diet, find a way to stay active, maintain your cardiovascular health, etc. It really is worth it, especially as you age.
Coding marathons are overrated. Sometimes the best code is not writing any or even better removing code instead of adding to it. I have always focused on effectiveness over output which helps.
I did however prioritise family and more recently self-care (both physical and mental). I have young children and they won't be young for very long so I am trying to spend as much quality time with them as I can (while remaining sane!). I am conscious though that as they grow up they will need me less, so I am considering where I want to take my career next - it's a big subject!
My time is also very fragmented and I do find that frustrating. I have a pretty interesting side project which I think could be popular and useful, but I really struggle to make consistent progress on it.
The issue I am working on at the moment is trying to balance doing stuff with my time (hobbies, career development, time with kids) against not doing too much (and ending up stressed). Tricky!
changes for me were more life events. marriage gave me partner but it was several years living together to really understand spouse and show proper love respect understanding they deserve. honestly I was just young and naive.
life and personal goals improved for better having first child. it gave opportunity to reprioritize and focus on what most important to me. working 70-80 hour weeks was feather I felt in my cap. good to have hustle but it was first time i truly empathized with coworker who have child and not work so much. and me realized working so many hours and relentless focus on productivity not most important thing.
other important lesson from working with difficult people and bureaucracy as my employers size ballooned. had experiences with intellectual dishonesty where my contribution credited to others. felt upset but mainly learned maybe my priorities and focus would better serve in me own company. why work so hard and help someone else become director or senior staff and give me ideas to company patents? I decided to start me own company.
I was aware that I was possibly at the top of my career potential, but as I have been freelance/start-ups all the way and thus not really had a career, I just enjoyed the work and the company, and paid off a bit more of my mortgage, IIRC.