Live data from Hacker News

Ask HN: Do you struggle to sleep after coding all day?

news.ycombinator.com

41–50 of 77 posts

Re: Ask HN: Do you struggle to sleep after coding all day?

#43
Definitely need some time between coding and sleeping, an hour or two minimum for me.

When my mind jumps around I try to do focus on a single boring task, like trying to enumerate all 50 states or think of a fruit and vegetable for every letter of the alphabet.

Re: Ask HN: Do you struggle to sleep after coding all day?

#44
post #33

I've tried melatonin, cutting out alcohol, f.lux, not looking at a screen for an hour before bed, but the one thing that has had the most influence on my sleep (for the better) is cutting out caffeine after 4pm. (relevant study: http://www.aasmnet.org/jcsm/ViewAbstract.aspx?pid=29198 )

All of the above + regular exercise.

this. if you race your mind whole day in highest gear, tired body helps a lot to drag it into abyss of good old hard sleep. plus gazillion other positive effects, if all is done right

Re: Ask HN: Do you struggle to sleep after coding all day?

#45
I'd recommend experimenting with some different meditation techniques. If you practice meditation, you'll sometimes find yourself actively try to NOT fall asleep!

Look up the "body scan" method (it involves resting your attention on & relaxing each individual group of muscles in your body). Puts me to sleep without fail.

Re: Ask HN: Do you struggle to sleep after coding all day?

#46

Sleeping takes practice like any other skill. If your bedtime is erratic, if your sleep pattern is erratic, if your environment is erratic, your brain isn't sure when it's time to go to bed. Pick a time for a week and go to bed then regardless of anything else. Try to limit light exposure for the hour before sleeping (no phones in bed) and see if that helps. The more consistent you can be, the more consistent your sl…

I hate the "no phones in bed" rule, and literally everything I do is PC-based or phone-based, so I stare at one screen or another right until I sleep. The f.lux and Twilight (Android) apps have been very helpful at making me feel more naturally tired when I should be. Additionally, the Sleep as Android app makes for a great way to track and log sleeping patterns, and has a nice adaptive alarm.

That's interesting because I tend to use devices in bed too but find my sleep time varies. I'll give the f.lux and Twilight apps a go!

Re: Ask HN: Do you struggle to sleep after coding all day?

#47
I've had this problem. Had trouble falling asleep, and when I did sleep I would dream about coding. I don't have this problem anymore. I credit two things with eliminating the problem... 1) Exercise. Preferably in the morning. I do 20 minutes of weight training in the morning, 4 days a week. I follow the StrongLifts 5x5 method. I walk two miles at lunch. 2) Valerian root. I just take it every day 30 minutes before going to sleep. When my head hits the pillow I'm asleep in 60 seconds and I sleep like a rock.

Re: Ask HN: Do you struggle to sleep after coding all day?

#48
post #37

Nowadays I've taken to creating a to-do list before setting out to code and I always make sure to add a couple of tasks that are somewhat simple and I'm sure I can usually complete before bedtime. That way, even when I haven't run through the entire list, I feel like I've gotten something done and the day has not been completely useless. It usually takes some of the edge off any worries I have.

This is a great suggestion and hits the point about "small wins". What do you mean however when you say simple?

Re: Ask HN: Do you struggle to sleep after coding all day?

#49
There's no silver bullet for a last minute, "Damn, this whole sleep thing isn't working", so plan ahead. Your body has an internal clock that reacts incredibly strongly to food and exercise. It's quite simple really. You don't need a lot of exercise, just some basic movement throughout the day like walking or pushups/squats if you're feeling ambitious. Make that happen before dinner. And make sure that you don't eat too late, certainly avoid late snacking if you can. Plus, hydrate a lot. Drink water every hour or couple hours if you can. This should all be really easy, and the benefits compound over time. Other tips also work like avoiding caffeine/alcohol, but what I mentioned should be a general baseline. Habits that you should always do, especially because some of the other tips are hard to perform consistently.

Re: Ask HN: Do you struggle to sleep after coding all day?

#50

Are you working, or staring at a bright screen, right up to bedtime? That seems to make sleep harder for me. A few things I've found that help me: - Exercise. I work out 8-12 hours/week. Being physically tired makes sleep easier. - Eat dinner >2 hours before bed and avoid late snacks. - No alcohol (I do have an occasional drink, but it always impacts my sleep) - No TV in bedroom. I either read for 30-60 minutes or ta…

Same here, unless I'm extremely tired then sleep comes minutes after staring at a bright screen.

When do you exercise though? I find exercise before bed makes it easier for me to sleep but others I've spoken to seem to get too pumped up!

Post reply on HN