It's extremely common to gradually move into a state of mind where you denigrate yourself – and the effort you've put forth in life. You need to ensure your own happiness, and no one in here, or anywhere else, can tell you how to do that. Mindfulness is a great tool, because it allows you to become more certain of yourself. To discover what it is that you feel and where it is you need to go.
That being said, here's what works for me: Acknowledging that creation is hard, but that I love creating and helping people around me. That family is important and love even more so. I also remind myself to do something new every day that somehow moves the boundary of what it means to be me.
Added note: A book that also helped me realise my own tendency to create barriers around myself was "The Flinch" by Julien Smith. It's awesome and I highly recommend giving it a read – and practice some of what it champions. I suspect you will gain a lot from it, but then again: Only you can know that.
1. Very few people leave a legacy. The people that do often didn't do it deliberately or intentionally.
2. They don't. There might be a few people half your age that know as much about programming as you do, but the majority don't. In any case, you are the worst person to judge what special thing you bring to the table. Go and ask one of these young people that you fear / respect / admire / think are knowledgeable and ask them to tell you what value you bring. The answer will surprise you.
3. A lot of people have pondered the meaning of life. Opinions differ on whether we've made any progress on that question. It's OK to go on a journey of "spiritual discovery" at 37; it doesn't require heading overseas to a monastery.