Wern Ancheta

Adventures in Web Development.

On Sleep

| Comments

As developers we tend to not give much priority to sleep. Most of the time its due to a lot of responsibilities: work, family, and side-projects. And oftentimes we even bring in our todo list in our mind when we go to bed. As a developer myself, I tend to get less sleep than what’s required. Sometimes not enough to fully function and be productive during the day. In this blog post I’m going to share some of the things I’ve learned about sleep.

Stages of Sleep

There are actually stages to sleep, its not just being awake or asleep. It is important that we understand this concept because its the core of what sleep is all about.

  1. Stage 1 – also called light sleep. This is where we drift in and out of sleep.
  2. Stage 2 – heart rate slows down and body temperature starts decreasing in preparation for deep sleep.
  3. Stage 3 – breathing becomes slower, blood pressure begins to drop, muscles becomes relaxed, cell growth and restoration occurs.
  4. Stage 4 – slow brain waves are produced.
  5. REM – Rapid Eye Movement sleep. This is where dreams usually occur. The body becomes immobile. Energy is provided to the brain and body.

Factors Affecting Sleep

There are 5 factors which affects sleep:

  • Light
  • Consistency
  • Activeness
  • Environment
  • Consumption

Light

Light affects the production of melatonin, a sleep hormone. Ample exposure to light during the day, and minimal exposure during the night 1-2 hours before sleep is recommended. The best light source is sunlight in the morning around 6-8 AM. For rainy days you can use light boxes. The main idea is that exposure to light helps produce serotonin, a neurotransmitter which affects sleep.

Earlier I’ve said that light exposure should be minimized during the night. But we haven’t really defined what light is. Light is not just the fluorescent light, its also the light which is emmitted by electronic devices such as laptops, tablets and smartphones. And if its not already obvious, the light which comes from a television is also light. As a developer I want to maximize the amount of time I spend doing something productive. And that almost always means staring at the computer screen until I actually go to bed. This is not good for sleep as it decreases melatonin production. A good alternative is to install flux. What it does is adjust the color temperature to adapt to the time of the day. This effectively reduces the bluelight which is bad for sleep. If you’re using a tablet or smartphone at night, simply look for similar apps. Blue light filter is a good one for android phones.

Consistency

Our bodies love consistency. The idea is that you should always sleep and wake at the same time. Our bodies have something like an internal clock. And if you’re consistent with your sleep schedule, you almost always wake up or feel sleepy at the same time of the day. You wouldn’t even need an alarm clock to wake you up if you’re consistent.

Activeness

Regular exercise is important. As developers, were basically one of the people with the most sedentary job. Our brains and fingers are the only part of the body that is moving. So to get good sleep we must make it a habit to have exercise of around 20-30 minutes a day. Quality sleep is all about temperature oscillation. The idea is that the higher the temperature our body reaches during the day, the lower it gets during the night. And the lower the temperature means more deep sleep. Take note that exercise a few hours before sleep is bad as it makes you active. Personally I prefer exercising in the morning as it completely removes the possibility of exercising too near before bed time. And it hits 2 birds with one stone, as I also get some morning sunlight while exercising. Jogging, cycling and running are good types of exercise.

Environment

The environment also affects sleep. The temperature should neither be too hot or too cold. Around 18-23 degree celsius is a good baseline. Turning on the AC is also good. It effectively lowers the room temperature and also blocks out outside noises because of its white noise. Its a no-brainer that to get quality sleep you must always sleep somewhere where you’re comfortable. Sleeping position affects the quality of sleep as well, the general rule is to always sleep in a position in which you are comfortable. But its always a good idea to avoid sleeping on your stomach, as it reduces the amount of oxygen that goes to your lungs.

Consumption

What we eat affects our sleep as well. Here are some foods which is good and bad for sleep.

Foods to consume
  • Cherries
  • Milk
  • Jasmine Rice
  • Banana
  • Sweet Potato
  • Turkey
  • Valerian Tea
  • Walnuts
  • Almonds
  • Cheese and Crackers
  • Lettuce
  • Tuna
  • Garlic
  • Chamomile Tea
  • Honey
  • Shrimp

Basically anything else which can help produce melatonin. Or foods which has sedative properties or natural muscle relaxant.

Foods to avoid
  • Alcohol
  • Fat
  • Dark Chocolate
  • Coffee
  • Soda
  • Spices
  • Chicken
  • Celery
  • Ice Cream

Avoid anything that is high on fat content or caffeine. Its best if you can avoid caffeine entirely as it stays on your body for long periods of time once consumed. Also avoid diuretics, a subtance which promotes the production of urine.

The general consumption rule is don’t eat too close to bed time. Eating around 2-4 hours before sleep is a good idea. 2 hours for light meals, 4 hours for heavy meals (dinner buffet). Another important thing is to stay hydrated, 8-10 glasses (8 ounces) of water is recommended. You can definitely consume more if you’re an athletic type or you sweat a lot. Always remember to not drink too much near bed time to avoid waking up to go to the bathroom. As a rule, avoid drinking too much water 1-2 hours before sleep. You can consume in small amounts (half a glass) if you want.

Sleep Supplements

Sleep supplements helps you fall asleep easier. Here are some sleep supplements which you can try if you’re having trouble falling asleep:

  • Valerian
  • Melatonin
  • Magnesium
  • Theanine
  • 5-HTP
  • Antihistamines
  • Anti-depressants

You can look for these supplements on Amazon or Google. Just be sure to consult your doctor before taking any of these supplements. Because some might negatively affect an existing condition that you already have.

As a general rule, sleep supplements should be avoided and should only be taken when you really can’t sleep. They are just short-term fix, and they can leave chemicals in your body which can take around a week to fully expel. These chemicals might make you feel sleepy during the day which is not good for productivity.

Napping

You can nap around 20-30 minutes to gain a boost of productivity and avoid feeling tired or sleepy during the day. The best time to nap is around 1pm after lunch.

Sleep Tracking

If you want to have an idea how much sleep do you get per night. You can buy a sleep tracking device. Currently there are two brands which dominates this market: Jawbone and Fitbit. Just search for those on Amazon and pick one that feels right for you. These devices gives you a detailed look on how much sleep you get. That includes all stages of sleep that I’ve mentioned earlier. Its basically a wearable device (wristband) which you can then connect to an app in your smartphone.

Sleep Disorders

There are lots of sleep disorder out there but I’m only going to walk through these two: Insomnia and Sleep State Misperception.

Insomnia

Insomnia is a sleep disorder characterized by difficulty or inability to fall asleep. It can be either primary or secondary insomnia.

  • Primary insomnia – means that your insomnia isn’t caused by any existing medical condition.
  • Secondary insomnia – means that your insomnia is a result of an existing medical condition such as asthma.

If you believe you have an insomnia, its better to consult it to a doctor. A psychiatrist can help in most cases. Because oftentimes what’s causing you to not be able to sleep is only in the mind. If a psychiatrist cannot help you, then look for a sleep specialist.

Sleep State Misperception

Sleep State Misperception is the inability to perceive sleep from wakefulness. People with this condition may report having only slept for a few hours but in fact they have slept more than that.

Tips and tricks on falling asleep faster

Finally here are some tips and tricks on how to fall asleep faster:

  • Exercise in morning. Brisk walking, jogging or running will do. If you have a bicycle you can also use that.
  • Take a warm bath before going to bed.
  • Read a boring book.
  • Use a todo list, don’t try to hold things in your brain too much. As a developer, I always have things I want to do. Be it playing around a new technology, a library or a programming language. Or watching video tutorials and recorded talks from conferences all over the world. Or finally start a side-project I’ve been wanting to do for months. Or read an article about what’s new in the world of web development. Or write an article for my blog. The list is endless. The idea of a todo list is to put as much things outside of your brain as possible. This way you don’t have to think about it or maintain it on your brain like a file that’s saved in a filesystem in your computer.
  • Get into a journaling habit. A bullet list of all the things you’ve accomplished that day will make you feel at ease and awesome about yourself.
  • Picture yourself as dead tired.
  • Relax your mind. Imagine a beautiful and relaxing scenery such as the beach or mountain top. Basically anything that you find peaceful.
  • Use air-conditioning to lower the room temperature. A cool environment will make you fall asleep faster.
  • Turn off all the lights. If you can go pitch black or near pitch black do it.
  • Hypnotize yourself. Imagine a pendulum swinging in front of your eyes back and forth.
  • Listen to relaxing music. Look for soft piano pieces by mozart and put it into your phone or mp3 player.
  • Get out of bed if you really can’t sleep. If you still can’t sleep 30 minutes after going to bed then its best to get out and do something that would occupy your mind. Like watching TV or reading a book. Just go back to bed once you feel sleepy again.
  • Change position. Put your pillow to where your feet is currently pointing.
  • Take some deep breaths. Inhale then count up to four then expel it around 8 counts. Then repeat again until you feel relaxed.
  • Listen to a sleep hypnosis podcast.
  • Replay all the things you did in the morning in your head.
  • Stretch like a cat, curl your toes, or rub your belly. All of this somehow triggers us to yawn, which signals our bodies that hey its now time to fall asleep.
  • Don’t watch the clock when you can’t sleep. This will only make it worse as it makes you more anxious and pressured to fall asleep faster. Forcing yourself to sleep is no good. Just remember that it will to you eventually.

Resources

Comments