# Anxiety and computer architecture

Computer architecture seems like a great analogy for some of the anxiety that I feel.

## Call stack fatigue

From [Call stacks in everyday life](https://adamzerner.bearblog.dev/call-stacks-in-everyday-life/)

> For example, before writing this article I was getting my dog ready for a walk.
>
> But then I realized that the kitchen needed to be cleaned, so I started doing that.
>
> Then I got inspired to write this article, so I started doing that.
>
> Then I got a text from my brother.
>
> I just responded to my brother.
>
> Now I'm going to finish up the article.
>
> After that I'll finish cleaning the kitchen.
>
> After that I'll finally go and walk my dog.

At it's highest point, the leads to a call stack looks something like this:

```
textBrother
writeArticle
cleanKitchen
getDogReady
```

Being in a state where your call stack has more than one item on it is something that produces some sort of uneasy feeling for me. Fatigue isn't really the right word, but let's call it that.

## Less instructions in memory

A computer program is basically a list of instructions. Do this, then that, then that, then that. My mind is often in a similar state, where it has a list of things it needs to execute. As if there is a todo list in my head that I am painfully aware of.

I wish it didn't work like this. Instead, here is an alternative architecture:

```
let alive = true;
let currentTask = firstInstruction;

while (alive) {
  currentInstruction();
  currentInstruction = fetchNewInstruction();
}
```

Notice the infinite loop? It's a [**_feature_**](http://www.hpmor.com/chapter/39), not a bug.

There is a tight deadline for this feature, and if we don't meet the deadline, _or_ if it ends up breaking at some point afterwards, the whole company immediately fails.

Anyway, that's a conversation for [another day](https://knowyourmeme.com/memes/this-is-fine). I just couldn't help myself. 

For now, what I was pointing at is the fact that there is only one instruction in memory at any given time. That instruction is executed. Then a new instruction is fetched from the database. Then that instruction is executed. Then a new one is fetched. So on and so forth.

Really, it's quite zen if you think about it. The "mind" is totally focused on the present. There is nothing else in memory available to distract it.

Memory here is analogous to working memory, and the database is analogous to long-term memory. Or, better yet, a piece of paper. Your working memory doesn't have that other todo list swimming around, clouding your thinking, producing anxiety. It's just purely focused on the task at hand. Then, only once it is finished, it 1) releases itself from the burden of thinking about this current task, 2) consults a piece of paper to "load" a new task in, and 3) proceeds to give it's full focus to this new task.

## Threads

A computer might look like it is doing multiple things at once when you have Spotify playing music, a file downloading, and a Zoom call open, all at the same time. That is actually just an illusion though. In reality, the computer is spending a few units of time on Spotify, then a few on the file download, then a few on Zoom, then a few on the music again. It's just that this happens _rapidly_. So rapidly that you don't even notice the switching.

My mind can be similar. The frequency of switching is obviously much lower, but it's high enough where it is unpleasant.

This is a subtley different point from the one in the previous section. In the previous section I was saying that just having other instructions in memory is stressful. Here I am saying that the process of switching between threads is stressful.

## Viruses

The solution here seems somewhat simple: just don't start open threads. Well, part of the problem is that we live in a world with so many stimuli, and it is so [tempting](https://www.humanetech.com/) to open them. But a bigger part of the problem is that "I" don't start them.

They just... get started. It's like I'm infected with one of those old school viruses:

![](https://malwaretips.com/blogs/wp-content/uploads/2015/02/Catchingvirus-com-virus.jpg)

## Universal

This is post is feeling too grim and personal. That's not really what I'm going for. I've been speaking about the anxiety that _I_ feel, but really I suspect that it's universal.

The thing with computer architecture is that pretty much all computers are built this way. Some things about them are different, but the actual architecture is the same.

Computers differ in things like how much capacity they have to hold lots of instructions in memory, how many threads they can handle, how quickly they shift between threads, how prone they are to getting viruses. Stuff like that. But given the architecture, you can't really avoid these things entirely.

Ditto for humans. Given our architecture, I think we're all destined to have these sorts of feelings. In which case, it's futile to try to prevent them entirely. And doing so is likely to cause disappointment and frustration, making things worse.

So what is the path forward? Work with what you have. Tweak the parameters that are tweakable, and accept the outcome.

For now at least. I don't want to discourage anyone from thinking big. Eventually I'd like to see a new architecture.