Optimize Your Body, Optimize Your Code

Past me would have laughed at this post. But diet, training, and sleep have done more for the quality of my thinking than any productivity system I've tried.

Past me would have never believed that optimizing my body would also optimize my mind. I was a programmer. The body was just the thing that carried the laptop.

Then I noticed a pattern. The days I coded best weren’t the days I had the most time, or the most coffee, or the most motivation. They were the days I felt good: slept well, eaten clean, moved that week. On those days hard problems felt tractable. On bad days the same problems felt like walls.

It took longer than it should have to realize this wasn’t a coincidence.

How your state changes how you think

There’s a specific feeling to coding when you’re stressed or depleted. You stop thinking architecturally. You stop asking “what’s the right solution” and start asking “what’s the fastest thing that makes this stop hurting.” You monkey patch. You add the if statement instead of fixing the underlying model. You know it’s wrong as you write it, but you do it anyway because your brain doesn’t have the bandwidth for anything better.

I’ve shipped code I’m embarrassed by in that state. We all have.

Contrast that with the days when you’re genuinely well-rested and clear-headed. Complex problems don’t disappear, but they shrink. You can hold more context in working memory. You zoom out naturally and see the shape of the problem before you start solving it. The fix that looked like three hours of work resolves into something obvious in twenty minutes, because you’re coming at it from above instead of fighting it head-on.

Stress narrows your thinking. Physical wellbeing expands it. There’s real neuroscience behind that, but more practically it’s something you feel once you’ve been at both ends enough times to compare them.

Cutting alcohol

Almost three years since my last drink. I don’t miss a minute of it.

This is the change that surprised me most. I never thought alcohol was affecting my cognition because I was never drinking heavily: a beer here, a few drinks on a weekend. The kind of drinking that’s completely normalised and that nobody around you questions.

But the sleep hit is real even at low amounts. You fall asleep faster and wake up feeling like you slept, but the quality is measurably worse: less deep sleep and more fragmentation. And poor sleep compounds. A few nights of it and your baseline drifts down without you noticing, because the worse baseline starts to feel normal.

Once I stopped entirely, the clarity took a few weeks to fully show up, and then it just… stayed. I can think further ahead, I’m less reactive, and I recover from hard weeks faster. It’s one of the highest-return changes I’ve made, and giving it up doesn’t feel like a sacrifice at all.

Weight training

Four to five sessions a week. Not to look a particular way, though that’s a side effect, but for what it does to my baseline state.

Consistent resistance training lowers resting cortisol, improves sleep architecture, and does something for mental sharpness that’s hard to quantify but easy to feel. My best thinking often happens in the hour or two after training. Problems that felt stuck come unstuck. I’ve solved more bugs on the walk home from the gym than at my desk staring at the screen.

The mechanism probably has something to do with BDNF (brain-derived neurotrophic factor), which resistance training reliably raises and which supports neuroplasticity and memory. But I didn’t start training for the neuroscience. I started for the energy, and the thinking improvement is what made me take it seriously for the long term.

Cold swims

This one is harder to explain without sounding like you’ve joined a cult.

Cold water swimming silences the voices in a way nothing else does. Not quiets them, silences them. In cold water your body has exactly one priority, and it isn’t whatever you were anxious about before you got in. The mental chatter, the background hum of stress, the problems you’ve been chewing on all just stop. You’re present in a way that’s almost forced on you, and for the rest of the day that silence tends to linger.

The feeling afterwards is hard to overstate. There’s a specific clarity and confidence after a cold swim, like you can walk into any problem and it will eventually yield. I don’t know exactly why it produces that, but it’s consistent enough that I trust it.

The science backs up what you feel. Cold water immersion triggers a large release of norepinephrine, with studies showing increases of 200 to 300%. That’s the neurotransmitter tied to focus, attention, and mood. It also raises dopamine in a sustained way, not the spike and crash of most dopamine hits but a baseline elevation that lasts for hours. There’s evidence it lowers cortisol over time with regular exposure, which loops right back into the stress-and-code-quality link from earlier.

There’s a reason the mental health research on cold exposure keeps producing positive results. It’s a genuine physiological shift, not a mindset trick.

I can only use this in winter, when the water is truly cold. The rest of the year the open water gets too warm for the same effect and it’s just a swim: still nice, but not the same thing. I don’t do ice baths. I swim in cold open water when I can and use a cold shower when I can’t. The threshold seems to be around 15°C or below for the norepinephrine response to kick in, and below 10°C the effect is stronger. You adapt over time, which is part of the appeal: the discipline of getting in when you don’t want to builds a resilience that carries over into other things.

The supplement stack

I’m skeptical of most supplement marketing, so I’ll only mention what I’ve actually noticed a difference from.

In the morning I take two things. Alpha-GPC, a choline precursor, for focus and working memory. Choline feeds acetylcholine, the neurotransmitter most tied to learning and attention, and I notice a real difference on days I take it versus days I don’t, especially during deep work. And creatine, which everyone knows for strength training but which is underrated for the brain. It supports ATP synthesis in the brain the same way it does in muscle, and there’s decent research behind it for processing speed and short-term memory. I take it daily whether or not I’m training.

At night I take two more. Magnesium threonate, the form that crosses the blood-brain barrier most effectively, for sleep quality and to quiet the background mental noise that makes it hard to fall asleep after a late coding session; it’s noticeably different from standard magnesium glycinate. And GABA before bed, which works with the magnesium for sleep onset. Whether that effect is direct or partly placebo I honestly can’t say, but the sleep I get on it is consistently deeper.

These four, with the training and the diet, are what make my brain feel like it’s running well. None of them is magic on its own; they’re part of a system.

Diet: mostly subtractive

I don’t follow a named diet. The main principle is keeping processed food to a minimum, not out of fussiness but because the effect on energy and thinking is obvious once you’ve cut it long enough to notice the baseline.

Processed food doesn’t just affect your body. It creates blood sugar swings that turn into afternoon focus crashes, a sluggishness that makes everything feel harder than it is, and a low-level inflammation that takes weeks to clear once you start eating cleaner. The brain runs on what you eat. Junk in, junk out.

The specifics: high protein, real food as much as possible, limit refined carbs, and don’t drink calories. Nothing exotic. The boring fundamentals beat any optimised protocol.

The thing past me would have found ridiculous

I used to think the “mind-body connection” was soft, vague self-help language, the kind of thing that belonged in a different conversation from serious work.

What changed my mind wasn’t a book or a philosophy. It was paying attention, and watching the link between how I took care of myself physically and the quality of my thinking become undeniable over time. The connection isn’t vague at all. It shows up in the clarity of my decisions, the quality of the code I write, and how fast I can reason through a hard problem.

Your brain is a physical organ running on blood, sleep, nutrients, and neurochemistry you largely control. Treating it as if it floats free of the body it lives in just leaves performance on the table.

The irony is that all the productivity optimisation I used to spend time on (task systems, focus techniques, better editors, faster tools) was working around the underlying problem instead of addressing it. The highest-leverage thing I could do for my output wasn’t a new workflow. It was taking the hardware seriously.

Think of the body as the hardware and the mind as the software. We spend money on extra RAM, better GPUs, and the latest Claude Opus API credits to squeeze more out of our tools, and then ignore the actual machine running all of it. You can upgrade both the hardware and the software for almost nothing. Sleep is free. Cold water is free. Lifting heavy things is cheap. Cutting out alcohol saves you money. The return on any of this dwarfs what you’d get from a faster laptop.