Experience is a nice thing, most of the time. We can see through the BS and concentrate on important things to make up for a slower brain, less stamina and decreasing memory, to a point where I think I am as productive, maybe even more, than I was 20 years ago.
The negative consequence of experience though, in my case, is I'm less excited about new ideas, more skeptic in general, which makes it more difficult to find the motivation that is needed to build something really significant.
And I mean, it's not very surprising, if you haven't made it big at 40+, that means you worked on a lot of failed projects, that makes it harder to believe you can change that.
Maybe some older folks here on HN, but younger people comments welcome too of course, could share their point of view on that question?
* Do meaningful work, whatever that means to you. Maybe it's picking a domain that helps people or society, or maybe it's some other criterion. Ask yourself what meaningful work is to you.
* Be mindful about your craftsmanship and always work to improve it. Try to write solid, expressive, readable code that works, and be critical about your own code. Read other people's code closely and see what you can learn from it. Explore new technologies, not just for "variety" but for what you can learn from what led to their development and how they were implemented.
* Engage in mentorship of younger developers. Mentorship can really do a lot to renew your love of coding. If your employer doesn't have an established mentorship program try to help set one up. If that doesn't work, there are coding bootcamps that will let you work as little as an hour a week mentoring new developers as a consultant.
* Try to be that person within your organization that others want to come to with their thorny technical problems. Listen deeply and respond compassionately.
* Work on side projects. They don't have to change the world or "go somewhere". A side project can remind you why you love programming when the daily becomes a grind.