The Code Was the Container

lived-experience #PTSD
Photo by Yen Vu on Unsplash

There are evenings when I sit down at my computer carrying more noise than I realise.

Not external noise. Internal noise.

The kind that comes from an unsettled nervous system, unfinished thoughts, old memories that have resurfaced, or simply one of those days where everything feels slightly out of step. The kind of day where concentration seems impossible and yet doing nothing feels worse.

On those evenings, I often find myself opening a coding project.

Sometimes it’s a tutorial for GraphitEdge. Sometimes it’s my personal website. Sometimes it’s a problem that has been sitting unresolved for days.

The screen fills with code. A missing bracket. A CSS selector that isn’t behaving. A component that refuses to render correctly.

And something begins to shift.

The outside world doesn’t disappear. The things troubling me haven’t suddenly been solved. What changes is that my attention now has somewhere to go.

The problem in front of me is small enough to hold.

For years I thought I enjoyed coding simply because I liked solving problems. There is certainly some truth in that. I enjoy building things. I enjoy learning. I enjoy the satisfaction of making something work.

The older I get, though, the more I wonder whether coding serves another purpose as well.

I think it helps regulate my nervous system.

What Regulation Actually Means

When people talk about regulation, they often imagine calm.

A peaceful mind.

A quiet body.

A state of perfect balance.

That isn’t how I experience it.

For me, regulation is less about feeling calm and more about having capacity.

Regulation, at least as I experience it, looks like:

  • Staying present when something feels difficult
  • Tolerating uncertainty without immediately spiralling
  • Experiencing emotions without being consumed by them
  • Having enough mental space to choose a response rather than simply react

Interestingly, this understanding is closer to how many researchers describe regulation. Rather than the absence of stress, regulation is the ability to move through challenge while maintaining enough capacity to think, connect, and make decisions.

One framework that resonated with me when I first encountered it was Polyvagal Theory, developed by Stephen Porges. The theory suggests that creativity, curiosity, learning, and problem-solving are more accessible when the nervous system feels sufficiently safe rather than constantly scanning for threat. Looking back, I can see that many of the activities that help me feel steadier share this quality.

Many veterans become very good at appearing regulated. Military culture often rewards composure, competence, and the ability to keep functioning under pressure.

The challenge comes later.

Eventually, many of us discover that appearing steady and actually feeling steady are two very different things.

I’ve spent years learning the difference.

Meditation helps.

Walking helps.

Knitting helps.

Writing helps.

And somewhat unexpectedly, coding helps too.

Why Coding Works

Programming has a quality that many parts of life lack.

It has rules.

The syntax doesn’t change its mind.

The computer doesn’t wake up one morning and decide that yesterday’s solution no longer counts.

I think coding works for me because it combines several things my nervous system seems to respond well to.

Coding offers:

  • Predictable rules The syntax is consistent. If something is broken, there is usually a reason.
  • Immediate feedback Every error message, save, refresh, and successful deployment tells me something useful.
  • Absorption My attention narrows onto one manageable problem.
  • A sense of completion Even if something is only “working for now,” there is usually a visible result.

The first of these is probably the most important.

Research into Polyvagal Theory suggests that predictable environments can act as safety cues for the nervous system. Coding provides clear rules, consistent feedback, and a level of predictability that many real-world situations lack.

Life often feels messy and unpredictable.

Relationships don’t come with documentation.

Trauma doesn’t provide useful error messages.

Grief doesn’t tell you which line is causing the problem.

Coding offers a small pocket of predictability inside a world that often feels unpredictable.

The immediate feedback matters too.

The system responds honestly to what I’ve done.

Not personally.

Not emotionally.

Just honestly.

There is something surprisingly comforting about that.

Then there is the absorption.

Anyone who codes regularly knows the feeling.

You begin with a simple task.

A small adjustment.

A quick fix.

The next thing you know, two hours have disappeared.

Your attention has narrowed until the only thing that exists is the problem you’re solving.

From the outside, this can look strange.

From the inside, it often feels peaceful.

The endless commentary in my head becomes quieter.

The background radio that seems permanently tuned to worry, planning, remembering, and analysing finally lowers its volume.

My attention has been given a job.

And it is fully occupied doing it.

Researchers studying autism and ADHD have explored the similarities between what psychologists call flow and what many neurodivergent people describe as hyperfocus. Both involve deep concentration, a distorted sense of time, and intense engagement with a task. While hyperfocus is often discussed in terms of its downsides, the experience itself can also create a temporary reduction in cognitive noise.

Reading that research felt familiar.

It described something I had experienced many times without having language for it.

The goal was never really the code. The code was the container.

There is another piece to this as well.

Psychologist Mihaly Csikszentmihalyi spent decades studying what he called flow — the state of complete absorption in a meaningful task. He found that people are more likely to enter flow when an activity offers clear goals, immediate feedback, and an appropriate level of challenge.

Coding frequently provides all three.

Perhaps that is one reason so many developers talk about losing themselves in the work.

The Difference Between Escape and Regulation

There is an important distinction here.

Not all absorption is healthy.

I’ve experienced plenty of occasions where hyperfocus stopped being helpful.

I’ve missed meals.

Ignored fatigue.

Stayed in my chair far longer than was sensible.

Surfaced hours later with aching shoulders, tired eyes, and a brain that felt completely depleted.

That isn’t regulation.

That’s simply another form of imbalance.

Escape vs Regulation

Escape Regulation
Avoids difficult feelings Makes space for difficult feelings
Disconnects from experience Helps remain present
Leaves me depleted Leaves me steadier
Driven by avoidance Driven by intention

The distinction isn’t always obvious while I’m doing it.

The activity itself isn’t automatically beneficial.

Work can become avoidance.

Exercise can become avoidance.

Reading can become avoidance.

Even meditation can become avoidance.

What matters is the relationship we have with the activity.

For me, coding becomes regulating when it helps me return to myself rather than avoid myself.

Avoidance says:

“I don’t want to feel this.”

Regulation says:

“I can feel this and still focus on something useful.”

One disconnects me from experience.

The other helps me remain present within it.

That’s why I see coding in much the same way I see knitting.

Both involve structure.

Both involve repetition.

Both create a rhythm that allows my nervous system to settle.

Neither removes difficult emotions.

They simply create enough stability for me to hold them.

What This Means for How I Work

Over time, I’ve learned that coding works best as a regulating practice under certain conditions.

The conditions that help coding feel regulating

  • I work best in the morning.
  • I choose tasks that match my current capacity.
  • I break large problems into smaller ones.
  • I stop before exhaustion becomes the price of progress.

Morning is usually my best time.

My thinking is clearer.

My energy is steadier.

My patience is greater.

I’ve also learned that the size of the task matters.

If I’m already feeling overwhelmed, tackling a major architectural problem is unlikely to help.

A small, well-defined task often works better.

Fix a layout issue.

Update a component.

Write a lesson.

Refactor a section of code.

Something with clear boundaries.

Psychologists Edward Deci and Richard Ryan, through their work on Self-Determination Theory, found that people tend to thrive when activities support a sense of competence, autonomy, and growth. Looking back, coding has often provided all three for me.

Perhaps that’s another reason I keep returning to it.

Not because it helps me avoid life.

Because it helps me feel capable of engaging with it.

Perhaps the hardest lesson has been learning when to stop.

There is always one more thing to fix.

One more feature to add.

One more improvement to make.

The discipline isn’t simply knowing how to start.

It’s knowing when enough is enough for today.

That lesson applies to far more than coding.

Coming Back to Myself

When people think about regulation, they often imagine activities that look obviously calming.

Meditation.

Yoga.

Time in nature.

A quiet cup of tea.

Those things matter.

I use many of them myself.

Yet regulation doesn’t always arrive in the ways we expect.

Sometimes it arrives through a line of code.

A syntax error.

A bug that finally reveals itself after an hour of searching.

A webpage that suddenly works exactly as intended.

The code was never really the point.

The code was the thing that held my attention long enough for my nervous system to settle.

Long enough for the noise to soften.

Long enough to remember that I am here, in this moment, working on one small problem that I can actually solve.

Not because I escaped into coding.

Because, for a little while, coding helped me come back to myself.


A Question to Reflect On

What activity helps quiet the noise in your mind without shutting you off from the world? For me, coding is one answer. For you, it might be something entirely different.

Related Reflections


Further Reading

The ideas explored in this article are based on both personal experience and research into attention, nervous system regulation, motivation, and creativity.

  • Porges, S. W. (2011). The Polyvagal Theory: Neurophysiological Foundations of Emotions, Attachment, Communication, and Self-Regulation.
  • Frontiers in Psychology (2024). Polyvagal Theory in Creative Arts and Psychomotor Therapies.
  • Ashinoff, B. K., & Abu-Akel, A. (2022). Hyperfocus or Flow? Attentional Strengths in Autism Spectrum Disorder.
  • Csikszentmihalyi, M. (1990). Flow: The Psychology of Optimal Experience.
  • Deci, E. L., & Ryan, R. M. Self-Determination Theory and Human Motivation.
  • Polyvagal Institute Resources: Understanding nervous system regulation and safety cues.