One controversial opinion in software is that your sleep quality and stress level matter far, far more than the languages you use or the practices you follow. Nothing else comes close: not type systems, not TDD, not formal methods, not ANYTHING.
This is my summary of Andrew Huberman's Master Your Sleep & Be More Alert When Awake | Huberman Lab Podcast #2.
My comments are [between square brackets]. Quotes are approximate.
TL;DR: view sunlight outside for 2 to 10 minutes in the morning, as early as possible, and before sunset. The spectral composition of low-angle sunlight controls the circadian rhythm much more than food or exercise. Avoid bright lights in the evening (or at least blue-ish lights), especially between 11pm and 4am. To fall asleep faster, practice Yoga Nidra, meditation, and sleep hypnosis, and use compounds if you need to: magnesium 300-400mg and theanine - 100-200mg 30-60m before sleep.
See my other post for the most effective sleep hygiene tips.
"Sponsored by Helix mattress" [I slept on one for a moth, very good actually.]
"Most people wake up about when the sun rises, maybe 1 or 2 hours later" [Not us programmers...]
"Get 2-10 minutes of sunlight exposure regularly, as early in the morning as you can, outside. Early in the day, your retina is not as sensitive, so it needs a lot of sunlight photons to set clock mechanisms. Sunrise light intensity & color temperature (from sun being low in the sky) is ideal to set our circadian and hormonal rhythm. Outside light intensity is ~1000x higher than indoors."
"It's 50x less effective to view the low-angle morning sunlight through a window"
[THAT would be the paradigm shift for me. I've known about light as a trigger of the circadian rhythm for decades, and got it through the window, e.g. by having breakfast by the window. But if you need 10 minutes of direct sunlight, you'd need 500 minutes through glass, i.e. 8 hours by the window. Might happen in an office setting, or might not.]
"The early morning light exposure needs to be done 2-3 days in a row for effects to manifest"
"Early in the day, the retina is not sufficiently sensitive to be disrupted by light, so it's OK to look at your phone if you wake up before sunrise; you need to look at the sun for longer if it's overcast"
"Blue blockers should be reserved for the evening (after 8pm), or if you wake up in the middle of the night and use screens (@53:15)"
[That was contradicted by this study on mice, which suggested that warm yellow light disrupts sleep worse than blue]
"Viewing low-angle light when the Sun is setting can help protect the circadian mechanisms against the negative effects of light later in the day"
[At 46 minutes in, he missed the opportunity to talk about sleep masks. Seems they're useless, because the eyes wouldn't see light while closed. I doubt that. You can still see strong light with your eyes closed.]
~"The longer you've been awake, the more sensitive the retina becomes, so even small amounts of light can disrupt your sleep patterns. Get as much light as safely possible before sunset, and as little after ~8pm; and no bright light exposure 11pm-4am"
~"Light that arrives in the eyes between ~11pm-4am suppresses the release of dopamine (endogenous antidepressant, learning facilitator)"
"Red light won't trigger these issues"
"The cells in our eyes that signal the central clock reside mostly in the bottom half of our retina which means it's viewing our upper visual field. To avoid improper activation of neurons, place light low in your physical environment, on desktops or floor." [I don't like lights that low, you inevitably look at them and get retinal afterburn]
"Candlelight and fireplaces are fine, very dim lights are fine"
"Shift work needs an entire discussion" [how about us PARTY GOERS?!]
@55:40 "If you turn on the lights ~45-60 minutes, even if your eyelisds are closed (provided you're not under the covers), that increases your total sleep time and makes you want to go to bed earlier each night" [this suggests sleep masks do make a difference]
"So the light does penetrate the eyelids and activates the neurons that control the central clock"
"You can advance or delay your sleep/wakefulness phase. If you see light late in the day, esp. in the middle of the night, your brain will think that's morning light, even though it's not sunlight, and will delay your clock, making you want to get up later and go to sleep later"
"If you wake up early (4-6-7am) and get light exposure, it will phase-advance your clock"
"..people's internal mechanisms aren't anchored to anything regular"
"If you can provide them consistent light anchors early in the day, and in the evening, and avoiding light at night, you'll be amazed at the tremendous positive effects - hormones, wellbeing"
"Most people are not familiar with what it is [like] to sleep really really well on a consistent basis"
"Naps of ~20-30m (up to one hour) can be beneficial. If you wake up from a nap feeling groggy, that means you didn't sleep well enough during the night"
"Non-Sleep Deep Rest: meditation, Yoganidra, hypnosis"
"NSDR can help with emotional stability, wakefulness, and falling asleep more easily at night"
- modafinil for narcolepsy
- adderall for wakefulness makes you feel more alert, there tends to be a heavy rebound, and there's addiction potential
- magnesium - increases GABA, makes mind drift in space & time. Magnesium threonate is the best for inducing drowsiness, 300-400mg 30-60m before sleep
- theanine - 100-200mg 30-60m before sleep
- 50mg of apigenin can support falling and staying asleep. It's an estrogen inhibitor; esp. important for women"
"Yoganidra - meditation you listen to that allows you to consciously bring your body to a state of deep relaxation; sometimes you fall asleep. It involves passively listening for 10-30 minutes to a script about body scanning and relaxation"
Sleep hypnosis - Reveri by colleague David Spiegel [I tried it once when I couldn't fall asleep, and it didn't work]
"It's very hard to control the mind with the mind. When you have trouble falling asleep, you need to work with the body to control the mind"
NB: try also this 4-7-8 breathing technique