I really like this answer and find myself in the same boat. Many times I will have an idea unshakably lodged in my brain (software architecture, philosophy, gaming, etc.). It excites my mind and my body follows suit with increased heart rate and breathing. Taking standard medication (Zzquil, melatonin, etc.) usually does not let me sleep when I'm in this state. So it's either lay there most of the night turning it over in my mind or just get up and explore the idea. Either way is only a few hours sleep.
I just roll with it. Sometimes it's a thinking idea and I just lay there and think about it. Sometimes I can research it or try it so I get up and do that because it's the quickest way to sleep. I'm tired the next day, but when it is a software-related idea, many times my work benefits on balance.
I've also found that if I try to put a lot of pressure on myself to sleep at certain times, I am less likely to be able to sleep for being stressed about it. So anyway, rolling with it is what I do. I sometimes wish I could turn it off and just go to sleep, especially when it is several nights in a row.
Thanks for your reply. Some time after posting this, I realized that I really have to wrote evening ideas down or even develop them to the end. I 100% agree with your point that in most cases we will eventually benefit on sacrifice a few hours of sleep.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.