Seems reasonable that you would struggle with the opportunity cost of your time when you're writing software for fun since you could also be working towards a greater goal of launching something that might make money.
Software is relatively unique because of the multiplying effects of software (without banking on a moonshot) unlike, say, carpentry or strumming a guitar. So the opportunity cost can be even higher.
You should always be cognizant of opportunity costs because they're always in play. And I can see that getting away from people, especially if you haven't already achieved your financial life goals.
I feel similar when I try to play a game in my 30s. It feels like a huge waste of time compared to something that would advance me towards my aspirations. But I think that's just part of being an adult. Just be aware of the trade you're making.