Stack OverflowSleeping problems, computer addiction
[+75] [53] Gili
[2008-09-18 05:24:55]
[ sleep personal ]

How do you keep your mind from racing late into the night, thinking about programming problems, keeping you awake? My sleeping disorder / computer addiction has impacted my personal life in a very negative way and I'm having a hard time doing anything about it.

Taking pills won't help because part of me wants to stay awake. I keep on telling myself "just 5 more minutes and I'll figure this out", but this goes on for hours.

Has anyone else experienced the same thing? How do you solve it?

Outstanding question... - ojblass
Just do other things, I can assure you working late into the night is not even going to help you be a better programmer, when you are tired you dont think clear. Get a good night rest, get a hobby. - alejandrobog
[+92] [2008-09-18 05:30:21] swilc0x [ACCEPTED]

Here's what you do:

  • Do not touch a computer after 7PM. Don't watch TV late into the night either. Read a book or magazine, work a puzzle - stay away from the TV and PC.
  • Exercise regularly. Doesn't have to be intense but do something. Try a 1-2 mile walk every other evening. It will do wonders for you.
  • Try to figure your sleeping rhythm out. Every 90 minutes or so, there's this moment where you feel extra tired. Identify the hour in the late evening when this happens, which should be fairly regular, and try to be in bed 15 minutes before that time.
  • No caffeine. In fact, try not to eat 3 hours before bed.

Do these things and you will sleep better.

Easy there. No caffeine!?! A caffeine ban three hours before bedtime is sufficient for me. - slim
(1) I notice a total caffeine ban improves my sleep even compared to a single morning coffee a day. Even a beer with dinner seems to wreck my sleep a little. Still... - Nat
!Caffeine for me starts at 5-6PM - BCS
(1) @Nat, one or two beers and I'm out like a light. - Simucal
(1) Caffeine was very difficult to get off off -- it was 2-3 weeks of agony, and maybe 4+ weeks total. In the end though, getting off of caffeine is very, VERY worth it. However, I disagree about not eating before bedtime -- a full belly really does help you sleep, but at the risk of getting fat. :-& - Mike Rosenblum
(1) I quit caffeine (except for whatever one finds in a chocolate chip cookie or the equivalent) and it has been delightful. You must get good sleep though, which for me is the hardest part - going to bed. Otherwise, a caffeine free lifestyle is so much better. - EnocNRoll
(1) Oh, it has be 76 days since I quit caffeine. On certain days I find it a bit of a struggle, but I do not find myself reaching for it, probably because it's the hardest thing I have had to ever do and I don't feel like failing it. I also keep a spreadsheet to log my work time and records like this. - EnocNRoll
A full belly does help you sleep, because your body is digesting the food which actually burns calories thus working your system and in turn makes you tired. That's why babies tend to have a nap after eating. On the other hand, food gives you energy too, so once that part is over, the energy can kick in and keep you awake. - Kezzer
(18) no pc after 7 and no caffeine mate? bleh, might as well change profession... - Andreas Grech
(1) I think I'd become a marathon runner before I gave up using my PC after 7pm. - Brian Ortiz
[+34] [2008-09-18 05:27:49] Brian Paden

I had this problem ( still do occasionally ). The best way I found to cure it is pure willpower. Set a bedtime, mine is 1 hour before I need to be asleep. So by this time I am in bed, lights off just waiting for my mind to cool down.

At first this is hard to do but patterns are very powerful tools.

Oh and keep a pen/paper next to your bed because often enough you will solve the problem by not thinking about it. This will test you the most, you really want to get up and fix it. Don't. Write down the solution and deal with it tomorow.

+1 for the pen&paper paragraph: this helped me immediately: I think about something, i write it down and bam I'm asleep :-) - David Schmitt
(2) Also +1 for that, but simply because I usually "solve" the problems i've been trying to solve for hours as soon as I'm away from my PC - On the Bus to or from work, in the bed, in a restaurant... - Michael Stum
Also +1 for the pen and paper - with practice you can just about make out your blind scribblings the following morning too! - Andrew
+1 for the pen and paper because everybody else thinks it's cool and I want to appear cool :P - Teifion
It was an afterthought but thinking about it, probably the most important part of what I said. - Brian Paden
+1 because not only does this help you sleep, but it often results in better software design in the end. Sitting at a computer is not the place to fix design. - slim
Another +1 for p&p: it's a tremendous stress-reliever to know I'll have a hard-copy backup of any epiphanies. - Adam Liss
+1 for the p&p part. my brain works better offline. - Artur Carvalho
[+25] [2008-09-18 06:22:49] Kevin Pang

Remember this simple fact:

Nobody ever died wishing they could have more time to write code

Programming is just a means to an end, or at best, an enjoyable hobby. There are far more important things in your life; don't miss out on them because you were too busy developing.

(3) Hm I'm not sure you're as passionate about coding as a lot of other people here myself included!! - kronoz
(3) Hehe! Do we have a non-believer? "Maaa! where's my pitch-fork?!" ;oP - Andrew
(3) I am passionate about coding, but you have to draw the line somewhere. Family, friends, love, happiness - all come before programming. There are priorities in life and sometimes programmers forget that. If your final words are "if only I had more time to write code", then I stand corrected. - Kevin Pang
My final words would probably be something like those. And being a social outcast helps you stay focused on the really important things, like thinking and programming :-) - RoadWarrior
I've tried staying away from programming - but it didn't workout I just got depressed... - Anders Hansson
Nobody says to stay away from it, just make sure you have some sort of balance in your life. There's bound to be something else that makes you happy other than programming, so make sure you spend some time doing it. - Kevin Pang
[+20] [2008-09-18 05:29:19] Bruce

Exercise is your friend. Depending on your level of fitness, this could be yoga, walking, running, or lifting weights. Exhaust yourself physically, and your body will do the right thing and put you to sleep. There are also other obvious health benefits of this technique. I must admit that this advice falls in the category of "do what I say, not what I do" - but I'm pretty sure it will work. Worth a try, anyway.

cannot agree more.. excercise WILL make you feel better. Every time. Force yourself to do it if necessary, just take a long walk or something. You can think about programming while you're walking! :) - Jeff Atwood
[+12] [2008-09-18 06:12:46] community_owned

The real root of the problem:

1) Normal human bio cycle is 25h

2) The typical sitting lifestyle of high tech professional creates WAY lesser load on your body then typical hunter-gatherer experience the body is wired too genetically.

3) the highly dynamic / changing setting generated by computer is setting our hunter-gatherer brains are wired to process in very alert and energetic fashion (hunt, search, real time analysis)

Result: Body is NOT tired, brain is high powered, and its 4am already!

Attacking different parts of the equation helps solve it as whole

1) Tire your body. Make plans to actively tire your body during the day. Running, biking, rollerblading, heavy yard work, etc. Amazingly enough even 30-60 min of sports make big difference in going down to sleep the same evening.

2) Melatonin is my friend! So is sominex and unisome. I think melatonin is better since its natural, yet sominxe/unisome are WAY more powerful. If i feel too energized i go sominex, and i take melatonin every other "normal" day.

3) small but valuable addition to melatonin is simple ear plugs available in every store. melatonin pushes your alertness down. ear plugs prevent more triggers from crossing that alertness. melatonin + ear plugs gives you very deep, restful uninterrupted sleep.

4) Climb it down. Its hard to go from full speed to zero, but it simpler to go slowly down in a course of a hour. when i feel its time, i take the pills, then take book, or notepad for design work, or laptop and go to bed. staying in bed with book/laptop is less intensive then full 4-monitor spread. when pills kick in in 30-40 min, all you need to close the lid/book and go to sleep.

5) the point is not about following arbitrary system, the point is in winning. if you feel you ARE in the zone, the code flying and intensity is high - don't break it! its uncommon enough to support it. when you feel you not going to be in the zone tonight/today - take the pill and convert the low returns time into rest and energy for next day.

Do you have a reference for the length of the bio cycle? I'm curious about that. - Scottie T
[+8] [2008-09-18 05:26:35] JP Richardson

I really enjoy reading before I go to bed. That usually puts me to sleep. Oh ya, and make sure it's not technology related. Read something semi-soothing... a self improvement book, novel, bible?, etc.

This usually works for me too. - Matt Refghi
[+8] [2008-09-18 13:55:22] Scottie T "Floating Brain!" Pear Press/ [1]

I've got to echo the suggestions of exercise and sleep. They're probably the two best things you can do for your brain. I recently read a great book called Brain Rules by John Medina. He breaks down what we know about the brain from scientific research into 12 simple, easy to understand "rules".

Two girls exercising Photo by Mike Baird

Rule #1 is "Exercise boosts brain power," and John describes how aerobic exercise encourages capillary growth in the brain, increasing blood flow and stimulating neuronal growth. Archeological evidence suggests our early human ancestors walked 12 miles a day on average, and we did that for thousands of years before Robert Propst regretfully [2] invented the cubicle, leading our bodies to be optimized for movement. So get away from your computer and exercise. It doesn't have to be anything too meat-heady, just get out and move. And while you're working out, focus on simple thoughts, like your breathing. That should give your conscious mind a rest while giving your unconscious mind some time to figure out whatever problem you're having at the keyboard. John believes in the brain benefits of exercise so much, he even installed a treadmill with a laptop stand in his office so he can check email while walking 1.2 mph. Man, I wish I could do that!

Yawn! Photowitch/

Rule #7 is "Sleep well, think well." While you're sleeping, your brain isn't. It's quite active replaying and reorganizing all of the information it took in that day. When you don't get enough sleep, your memory suffers terribly. When you do get enough sleep, your brain thrives. One NASA study showed pilots who took a 26 minute nap [3] improved their performance by 34%. And stay away from the caffeine [4]. One or two cups of coffee a day won't hurt, and some studies suggest it may improve your memory, but too much caffeine on a regular basis tears up your arteries from the inside and causes lots of other negative effects. Now I've pulled my share of all-nighters getting my code to work (mostly in when I was in grad school part-time), and I downed the Rockstar like, well, a rock star. But I try to avoid that as much as possible.

EDIT: Sorry about the absurdly long link! I don't know how to fix it. It looks good in the preview.

EDIT 2: Trying to clean up the link problems.


(5) The second photo is all the motivation I need to go out and exercise :-) - Justicle
This answer needs more clip art. - Pete
[+6] [2008-09-18 06:58:12] rasyadi
  1. Know you priority. Keep in mind of what is urgent and important first. At 2 a.m. sleep is very urgent important because you need it to be productive on the next day.

  2. Do other things. I believe geek life is not just in front of the computer. Switch to another thing like reading books or watching discovery channel.

  3. Make a TODO list of what need to be done. Not for do it now, mark it as the task that should be done when you are wake up in the next morning.

  4. Take a break regularly. Let say for every 30 minutes, take a walk around the house, look at the sky. You will know there's a life outside the computer.

  5. You need a rest. Enough of what you have accomplished today. You can reward yourself by going to the bed and consider it as a big accomplishment because at last you can stay away from you computer. This can be as a source of motivation on the next day. Remember that you have enough sleep last night and there should be no reason not to be productive on the next day.

[+5] [2008-09-18 06:39:19] Nat

Gili, you are suffering from stress. It is characterised by elevated levels of adrenaline (i.e. no sleeping). Stress has a number of negative health effects, including you know, early death.

While most of the advice here is good advice, see a doctor or suitable health professional.

Probably best not to ask IT professionals about health problems, particularly those that would not reccomend seeing a doctor as a good idea.

Yes, it is possible to enjoy stress (=excitement), but too much of a good thing...

[+4] [2008-09-18 06:09:55] community_owned

Most of the answers people have posted so far are equivalent to telling a mentally retarded person: "just think harder". Your drive and motivation to stay up late is more likely to be biological in origin rather than intellectually driven.

I would most likely suspect you are suffering from either hypomania or bipolar disorder. Don't scoff at this possibility. It is a disorder that is very common amongst people who do creative work, such as musicians, writers, artists, AND computer programmers.

I'd encourage you to take this seriously and go see a psychiatrist as they can prescribe medications that aren't sleeping pills, but will stabilize you and make your sleep patterns more predictable. Why live another day with this frustration? There are proven solutions. Visit a shrink. Now.

Uh. I think thats a little alarmist. There are fairly reasonable ways to improve sleep before getting psychiatric medication. - Justicle
Bad analogy, considering the rest of the answers here work reasonably well. Also, I'm of the opinion that those types of diagnoses by psychiatrists are questionable, as are the medications they prescribe. Many of these disorders are "voted in" rather than proven. Your urgency in suggesting this approach concerns me. - Syntax Error
[+3] [2008-09-18 05:33:33] DGM

Have a notepad handy by your bed, so if you do have a true "AH HA!" moment, write it down so you don't forget it! Otherwise, I always have to read something - and to avoid getting too caught up in the book, it's usually some old that I've read a lot of before. LOTR, Clancy novel... Bible is always a good one... :)

Sleep is a good thing though - many times a difficult problem has unwound itself while I sleep, and the next morning I look at the code and realize it was something dumb like forgetting a semicolon.

[+3] [2008-09-18 05:34:31] Martin W

First, tell yourself it's time to stop and get ready to go to bed. To stop worrying about "just one more thing", write down what you're doing and what still needs to be done. That way, you can still be on a roll tomorrow after you wake up. Making a list of everything you need to do tomorrow can help you "let go" and think about other things until you need to be working on tech stuff again.

Keep a pen and paper or a recorder next to your bed. Try to stop thinking about the technology related things you've been doing. If one pops into your head with some new ideas, you can write it down. Writing is very cathartic and will make it much easier to think about something new.

Also, turn off any clocks. I heard this suggestion a lot and thought it was BS. But after a move I didn't have a clock anywhere visible from my bed. I found that I fell asleep much easier. You don't have to worry so much about falling asleep if you can't keep track of what time it is.

[+2] [2008-09-18 05:38:50] user17263

Scott, play with the kids! Read them stories instead of sitting in front of the computer! :P

er, Scott didn't ask the queston - Duncan Smart
[+2] [2008-09-18 05:31:35] Paul

You might have bipolar mania... I would see a doctor.

Edit: regarding the comment below... please notice the wording... "You might.." it's not a medical diagnosis!

Talking to a doctor might give you better answers than asking a bunch on techies. I think I have a good point here.

Why did this get voted down? What if he's right? Sheesh. - MrBoJangles
seems like a big jump to "bipolar mania" to me although seeing a doctor is never bad advice - Jeff Atwood
Yeah, I dunno. Developers. Bipolar mania. Not sure if it is a huge stretch...? - Nat
I think making medical diagnoses on a programming Q&A site is a little bit freaky to be honest! Dude you need QuackOverflow for that! ;-) - kronoz
[+2] [2008-09-18 06:31:21] Nikhil Kashyap

I feel reading always helps. I have a huge stack of Calvin and Hobbes that I read before going to bed. I've found that it not only lightens up the mood, but also makes you laugh. What better way to end the day than laughing?

[+2] [2008-09-18 06:31:31] Nathan W

I have the same problem. I find just getting a good book to read or doing some drawing really helps me break away from the PC, or sometimes even just playing a bit of "Wii Fit" to get up and moving can sometimes help me get away from the "all I can think about is computers feeling"

[+2] [2008-09-18 15:40:39] JBB

Pzizz [1] has worked wonders for me! I've gotten pretty good at mental relaxation "exercises" to quiet down the racing thoughts in my brain, but when I can't manage on my own I stick on a set of headphones and play one of the Sleep tracks [2], lie back and relax.

I've also found their power naps helpful.

In addition to this, I highly recommend:


Write things down to get them off your mind (you can think about them later)

Be in bed at the same time every night

Get up at the same time every morning! This is crucial and a lot of people seem to forget it!

Consider a Dawn Simulator alarm clock. This helps me a lot with getting up at the same time daily.

Consider a SAD (Seasonal Affective Disorder) lightbox -- use it first thing in the morning over a cup of coffee or an email session. Helps get the ol' metabolism going.

EAT BREAKFAST -- again, get the metabolism going!

Honestly, for me the morning routine seems more important than the evening routine -- other than keeping things off my mind when it's time for bed.


[+1] [2008-11-12 04:41:04] Adam Liss

You mention the problem "impacts your personal life," which means you still have one. Have someone distract you from the computer shortly before bedtime. Details are left to the creativity of the reader, but part of the process should include turning the computer off so you'll be less likely to go back to it.

Ok, I confess I don't turn mine off at night, either. At least turn off the monitor; it's powerfully symbolic. :-)

[+1] [2008-11-12 04:45:44] Leonard

The answers already given about avoiding TV and the Computer for a good long while prior to bedtime are excellent advice: A sleep specialist MD I consulted told me that light stimulates the visual cortex and interferes with the brain's natural cyclic shutdown. Other tips included letting your body going into its natural cool-down cycle (avoid a hot tub), stay away from alcohol, read stuff that isn't going to stimulate you -- he liked professional journal articles as opposed to novels. Get up at the same time each morning (Even on weekends).

[+1] [2008-09-18 14:11:42] Gordon Mackie JoanMiro

One word: melatonin.

[+1] [2008-09-18 14:12:42] Karl

I listen to podcasts. Concentrating on the podcast helps to power my brain down and then sleep comes easily, especially if I'm tired.

[+1] [2008-09-18 14:28:47] J16saw

Having had the same problem for years I now have a routine:

Always read before I try to sleep, if I am reading some technical book then make sure I have something non-techie to read for a bit afterwards.

Always have milk and honey with biscuits, might sound a bit lame, but I know it helps me and also informs my body that it is time for sleep.

When it comes to turn the light off and actually sleep, if my mind is racing then I focus on one thing, and one thing only, if my mind wanders off then bring it back to the one thing. It has to be quite a narrow subject to avoid getting off the topic, for example a particular class within a module, or one specific design problem. By exhaustively concentrating on the topic I find I fall asleep quite quickly.

That maybe sounds a bit bizarre but after several years of doing it I have found that it works for me, even if I can't remember the solution the following morning!

[+1] [2008-09-26 09:27:31] Anders Sandvig

Read Power Sleep [1]. It changed my view on sleeping in general and sleeping "disorders" in particular.

As others have pointed out, most sleeping problems are psychological, and this book references a lot of interesting research in the area of sleep. It also contains a lot of practical advice on how to "optimize" your sleeping.


[+1] [2008-09-18 07:35:10] pobk

I have a similar problem. I found that the best way to get around it is actually to go out.

Go grab some friends and goto the flicks, a cafe, a bar, a library... Anywhere where accessing a computer is quite difficult.

If your friends are like minded the conversations will often veer towards technology anyway which is where you'll get your tech fix...

Once you come home, chill out... Watch a little TV or read a book. Don't even check email because the danger is that you'll get an email "Can you just look at this..." and it'll start again.

The idea is just avoid the computer.

[+1] [2008-09-18 10:47:11] Dan Harper

Stop running your own business... oh no wait, that one's for me ;-)

But seriously... the stress issue is huge, I've found getting another hobby I really enjoy can help break the cycle. I find tennis really enjoyable and it gets me some exercise and away from the computer.

If you don't enjoy it, then you won't do it, so make sure it's something you enjoy doing away from the computer.

[+1] [2008-09-18 05:33:16] moobaa

Engaging in mentally stimulating activities directly before attempting to sleep is always going to result in problems - the mind will carry on with the work, and the sleep won't come.

You've just got to wean yourself off the rush that problem-solving can provide. The problems will always be there, and a good rush first thing in the morning can replace your coffee.

If you really believe your addiction to problem-solving is an issue, seek out a cognitive therapist - their goal is to help you understand how and why you think the way you do. As soon as you realise why you're gleaning such a rush, you're in a better position to counteract it.

[+1] [2008-09-18 05:31:26] Subimage

The problem is not that you can't sleep, but that you conform to the social norms of sleep :)

Work when you feel creative, sleep only when you're tired. I find I'm much more productive this way.

Of course, this only works well if you're a freelancer or work for yourself. The 9-5 gang can't follow this advice.

For those that can't, look into melatonin.

I can understand why this was voted down, but I partially agree with it. I found that my best working time is usually 5-9 and I prefer to sleep from 9-5. Some people just have a different sleep cycle that may not always be compatible with your working hours. - Michael Stum
I used to think this way, but it eventually ruined my life. No joking. You can do this when you're living out of your dad's basement but the second you move in with your partner your whole world will change. - Gili
Gili I live with my girlfriend. She doesn't seem to care. Just depends on the partner you choose :) - Subimage
[+1] [2008-09-18 05:31:33] Rob Cooper

Ah a toughie, something many geeks can suffer from.. I often find myself staring at the ceiling or wanting to "just get this bit done"..

  • First of all, GET OFF THE COMPUTER! It's too easy to keep thinking and doing more when it's right there.
  • Have a relaxing hot drink, malt drinks or hot milk are good because they naturally contain chems that make you feel sleepy.
  • Reading can help, especially fiction.. It takes your mind off the programming and will help make you tired.
  • Get used to "clearing your mind".. Close your eyes, listen to relaxing music.. Just STOP thinking! It takes some practice, but once you start to get it, you can refresh yourself quickly.. I recently wrote a blog post on " keeping fresh [1]". Even though the post is actually focused on working more, you may find some points about "doing something else" useful.

[+1] [2008-09-18 05:39:39] kooshmoose

This normally occurs for me if I'm writing code just before I go to bed. If I'm not exhausted then sometimes my brain will wander and I can't fall asleep. Other times working late might affect my dreams and I'll get really bad sleep while I'm working on problems.

The solution for me is to just not do work right before I go to bed. If you "can't" keep away from problem solving before you try to sleep then you probably need help from a professional. Alternatively, you could always set an automated task on your computers which forces them to shut down at, say, 1 AM.

Good luck.

[+1] [2008-09-18 05:38:20] Roman M

Moderation is a key concept in my general approach to life, not just programming. You need to understand that anything in excess is probably not good for you and you have to find a balance that work for YOU. Whatever your occupation, you need to be able to master self control and self discipline, and part of that practice is to command your mind to think about a problem, and then do a 'context switch', to be able to let go and turn your attentio to other things (such as sleeping). In the long run if you acquire this control it will let you avoid burnout and other associated problems at work.

What I'd do is to create a schedule and force yourself to stick to it not matter what.

[+1] [2008-09-18 06:25:23] Robse

I think the realization that you don't want your life to go on like that is a very good step in the right direction :)

I think to succeed here you need to actually change your life pretty drastically, because you will need a clear cut between work and family life. I can recommend excersize to help you reach this. You have to accept though, that the considerable time you spend on this (I try to do it everyday, at least an hour) is reserved. But it will benefit you in many ways (also possibly high blood pressure) so...

[0] [2008-09-18 06:20:23] icelava

Establish objectives and milestones for the work you need to do. You can then decide what needs to be done today, what can be offset for tomorrow onwards.

Y'know, it is like those video games that do not allow you to save the game at any moment you like. You need to reach a "safe point", a milestone, before you can save your progress.

There will be some times, of course, when you simply cannot clear the level properly to reach the safe point. You should then consider abandoning the quest and starting over the next day. I know I have done that many times playing games, and do so similarly with work.

[0] [2008-09-18 05:52:28] RWendi

I experience the same problem, wish 1 day = 36 hours (lol). I think most programmers have similar issue. I find that regular exercise helps alot. It keeps you in balance and makes you feel more aware of your health. Try to set boundary of your working hours, and stick to it. The most important thing is that you have to be focused and motivated to realy control yourself. I usually use my people surrounds me as my motivation, because every litle thing that I do affects them. Just my 2 cents.

[0] [2008-09-18 05:28:57] Svet

Just take it out of your system - program as much as you can for a couple months and then it'll ease for a while. It usually works in cycles for me.

[0] [2008-09-18 11:12:45] community_owned

No caffeine certainly helps.

Finding a different hobby also helps, like photography or painting or sports. So sometimes I just went out and play tennis with my buddies, went home exhausted, took a shower and passed out!

[0] [2008-09-18 11:17:45] Stephen Denne

Create a daily recurring calendar entry telling yourself to go to bed.

Each time it pops up, snooze it for 10 to 15 minutes rather than dismissing it.

The continual popping up/snoozing will help you realize that you didn't solve it in 5 minutes, will help you realize how late it is getting, and will keep reminding you of your intention to go to bed.

[0] [2008-09-18 11:59:01] fuzzbone

There is already lots of good advice here - particularly about reading and cutting down the caffeine. You didn't put your age on your profile - but if you are getting past 30 - you'll find your body is changing and sleep is getting harder (especially true as you get through your mid 40's) I don't turn clock off, but I make sure it's turned away from the bed so I can't see it unless I physically get up to look at it.

The key thing is to be as calm and relaxed as possible. I like to try to "visualize" a calm and relaxing place. My wife and I went to France on our honeymoon - and we went for a walk on a park on a hill overlooking Nice. In one direction there was the view of the city - and the other the Mediterranean. I try to “take myself” there – imagine I’m walking through the park and sitting down at the café. The key thing is to clear your mind.

[0] [2008-09-18 12:09:36] Dan

I've had this happen fairly often; although, I find I'm not limited to programming problems. My mind races on any kind of puzzle/challenge that really captures my attention. What I found that works is to go watch TV, something completely different, such as Family Guy. The episode format (30 minutes) keeps me from clock watching, and the submersion into humor (even bad humor) lets my mind stop racing. I then go to bed.

Good luck.

[0] [2008-09-18 12:29:57] Garry Shutler

Realise that those five minutes will be more effective in the morning after a decent night's sleep. Set your alarm five minutes earlier if you want to. Your mind will be fresher and have been subconsciously running the problem over.

I find using logical arguments with yourself works well as a programmer.

Get into a routine of having at least 30 minutes of AFK before bed. Reading fiction can be very helpful to take your mind off of coding problem.

[0] [2008-09-18 12:51:58] kronoz

Perhaps your job isn't challenging you sufficiently. If you are left thinking about programming problems in the evening you may be compensating for having not been sufficiently intellectually stimulated during the day.

I often find myself trying to squeeze as much time as possible out of an evening in order to work on interesting programming problems, reluctantly aware of the fact that I have to move some header on some report + debug some awful legacy code all day tomorrow.

However I think it's good you spend time in your spare time to focus on programming, the best coders are constantly practising and developing themselves. swilc0x [1], dude, the people that follow that advice about not thinking about programming post-7pm are the kind of developers I don't want to work with, i.e. the 9-5 'it's just a job' brigade.

Kevin Pang [2] - I couldn't disagree more, as I'm sure many others would. I for one might well die hoping I'd written some more code. I'm very passionate about programming, how is that different from the many other passions people have in their lives?

Having said all that I think it's important to solve this problem, and I totally agree with Brian Paden [3], it's a matter of willpower and just switching everything off and lying there. Eventually your brain will get the message :-)

[1] #90292
[2] #90483
[3] #90279

[0] [2008-09-18 13:36:15] Gravstar

You need to take control on yourself. I will try to list some points that I have applied successfuly to my self. IMO pills are only hacks, you cannot relay on them to solve your problems. This must be done by your "I".

  1. Belive or not your brain is "like" a computer. You can program it to improve yourself. But you must take care of it! It needs to sleep. Some people needs 6 hours, others 10. In my case between 6 and 8 is fine. You must know how much time is enought to you.
  2. I try to work with computers only by day, but several times i have to work at night (because i love computers or due my work).
  3. Take into account that when you are working with computers you brain is hard working and you aren't perceiving the real world (is like you are in another world). So after the job is done, you should come back to the reality giving a break to your brain, let him gets its common activity. In my case I used to read a book/comic for a while.
  4. Use some kind of timer. I use Minutes (OSX dashboard) to control the time i spend on my work. If i'm playing WoW (World of Warcraft) i try to get into the bed not latter than 4.30am (only during weekends).
  5. Programming is like puzzle solving. I love to solve them, but i should not be thinking on the all the time because it could be insane.
  6. Buy a moleskine notebook (or whatever other brand) and get used to writte down all your thinkings about programming. If you are playing with some programming problem and can't solve it, then writte down where you are and go to sleep. Tomorrow when you awake you can come back to your notes just to refresh your memory (like virtual memory works). Belive or not because your brain has rested he will reward you with the solution.
  7. And of course, go for a walk and take some bears (or your favorite drink) with your friends. May be someone has the solution to your programming problem, who knows?

[0] [2008-09-18 08:04:01] user17384

Exercise at least 2 hours before sleeping. Eat at least 3 hours before. If that doesn't work take a good swig of beer or such right before. Not a whole pint or anything, just a minor bit... sometimes it works, sometimes the thinker is going to keep going regardless of what you might need to do, wanting to figure something out is generally much more powerful than simple needs - like sleep.

[0] [2008-09-18 10:38:04] Stephen

Above all don't take the computer/phone to bed. It's not bad per-se, they just keep you awake in ways a book can't. It's probably the light levels from the screen.

[0] [2008-09-18 06:43:58] Marcel Tjandraatmadja

I agree with the suggestion of most people to exercise, specially if it requires your full concentration.

I personally practice Aikido and it keeps my head busy during training. After training my mind is usually clear and I feel that I can solve problems heaps better!

Though sometimes I might get myself trying to figure out some tricky bit that happened during training, and then I end up trying to solve two problems instead. :)

[0] [2008-09-26 09:36:50] Kramii

I'm learning to "Sharpen the saw". Just as a saw works more effectively when you maintain it, so does my brain. When I recognised that I actually solve problems quicker if I sleep on them, then I found it easier to let go and get some sleep.

I also find that taking care of myself properly in other ways helps, too: good food, a proper routine, excercise (still struggling with this one), focusing on other things / people, prayer, meditation etc. all help me.

[0] [2008-09-26 09:51:30] cheeves

I used to have the same problems when I worked at home... I know it won't any good to Scott but a couple of cans, or a glass or 2 of wine used to help me

[0] [2008-11-12 04:04:24] Jon DellOro

I agree with exercise as part of an answer to this. Biologically, we're designed to a lot of it. Also, we're supposed to (basically) go to sleep at sunset, and wake up at sunrise. Try camping for a week without using any artificial lights, and sure as taxes you'll rapidly take on this sleeping pattern.

For these reasons I would agree with the Melatonin approach and the sunrise lamp alarm. Personally for this, I would try last any suggestions that advocate seeing a western-style medical practitioner. Maybe first see a Traditional Chinese Medicine practitioner or similar; they've been around for thousands of years and are paid when people in the village are well, not when they are sick. I think your final thing to try if nothing else is effective, is to take drugs to change a "disorder". Our ancestors didn't have those things. Maybe try the camping thing for a week and see how you go, huh?

(Part of) my solution was to take up martial arts. Prior to this most of my peer group were technology people, and it was somewhat surprisingly quite a shock to spend time with non-IT people. However I've found that a good experience in itself, although very challenging at times. In fact, I've found coming to understand and relate to the range of people at karate as challenging as the work itself.

After 1-2 hours of workouts and drills, both your mental and physical bodies are exhausted. And with one of the better types of clubs, the culture will incorporate a healthy attitude of self improvement as well.

Just one thing, you have to be careful not to start doing the same thing again, but now with martial arts. I started training at 7pm last night, and didn't leave the dojo until 12:30. Oh well, at least it solved my up-late-at-the-computer behaviour. :)

[0] [2008-11-12 04:25:23] John T

I think you've already made a big step into calming your addiction. I know a lot of people who are still in denial that they spend too much time on the computer (whether it be games or instant messaging), at least you realize your problems and that is the biggest step for some people. Now that you realize whats wrong with your situation, act upon it. You said you enjoy programming, write yourself a program that pops up every hour or something to annoy you to get fresh air, or go for a walk. Anything that will help you.

[0] [2008-11-12 04:51:07] BCS

MY (bad) solution is to program (or read, or whatever) till I'm about to get tired and then go to bed.

The only good part is the part about not going to bed if your not tired and to go to bed if you are. Laying around in bed, not going to sleep doesn't do you any good at all. (just don't go back to programming)

If you are worried about programming soaking up to much of your life, then do something else last thing before bed, hang out with friends at the coffee shop or what not.

[0] [2009-01-10 18:56:51] Dave Swersky

If you are working toward a large, long-term goal such as releasing a product or building a website, pace yourself. Set realistic milestones so you know when you're on track. That way you know when you can afford to take a break.

If, however, you are obsessively working with no particular goal to achieve, you may need to consider this a medical issue. I didn't address my sleeping issues until I got married. The path I took to resolve my own sleeping problems changed my life.

What path did you take? - Gili
Started with sleep studies and CPAP, which I had tried before I got married with little progress. Eventually led to surgery on my nose and throat, which is a fairly extreme step but in my case it made an enormous difference. - Dave Swersky
[0] [2009-07-22 06:05:31] community_owned
  1. Don't use the computer past 7:30. And avoid bright lights. The light emitted from your computer interferes with sleep-inducing chemicals in your head. And also, most people who say they're aren't afraid of the dark really are. Train yourself not to be. Don't use the night light!
  2. Eat whole grain foods, chicken, fruits, and don't skip breakfast. I remember when last year, I couldn't wake up early enough to eat breakfast and I had greasy pizza and hamburgers at lunch with a bunch of junk food and candy on the side. The problem with sugar is that based on the Biological structure, sugar gives you a high amount of energy for a short period of time and suddenly drops down. So you end up more tired.
  3. Early to bed, early to ? :)
  4. When it's time to sleep, close your eyes. If you're not feeling tired, don't watch television. Read! That raises IQ. Ari Bruening, one of the 13 students in the United States who got a perfect score on the Standardized Tests (SATs), said 5 exercise yourself to exhaustion. a standing jog while catching up news on TV is what i do

QUOTE When we were kids, we were expected to read, not to watch TV.

[0] [2008-09-18 15:50:12] watchwood

Take up a hobbey of some sort. I play a game of magic or two pretty much every day during lunch, and it works wonders for my concentration; and screwing around with my decks before bed is a good way to unwind.

[0] [2008-09-19 21:34:12] JB King

I've experienced it a few times, generally with dread over something having to be done ASAP and I've spent at least a few days on the point that I'm stuck. Part of a solution is to keep things in perspective: Will the world end if I don't figure out how to do ABC by tomorrow? Why do I feel like I'm obsessed with this puzzle or problem? Those are a couple of things to ponder.

Another tact is to get your body into a routine, e.g. go to bed at 10pm each night for a few weeks. If you can get into a habit, that can also help with some of the sleep and restlessness as your body generally will have cues on when to eat, sleep, etc.