The first assembler programming I did was for the 6502 chip in my Atari 400. It had a 256 byte stack1. That is not a lot of memory. That said, for most purposes, it was absolutely fine, unless you used deep recursion2. The stack was also used for temporary storage. The 6502 has three working registers, so if a subroutine wanted to preserve them, it would push them all to the stack when it started, and pop them off the stack when it was about to return. If you messed up the stack, the next return would likely pull a nonsense value into the PC and you'd get a very bad crash indeed, often locking the machine.
Today, we blow our stacks all the time. I'm not talking about code anymore, of course, but I think you know that. Think about a hundred open browser tabs. Do you recall why you went down those rabbit holes? No? Then you've blown your stack.
We start a day with good intentions, and before we know it, we are not doing what we intended to do, and we don't know how we got here. We have blown our stack. We are Theseus, and the ball of string Ariadne gave us to negotiate the labyrinth was dropped somewhere because we got distracted by ohhh shiny!
Computers were supposed to help us with this problem, they were meant to be Ariadne's ball of string, but instead of us using it to get to our goal and return, to call a subroutine and return, we are tying ourselves up in knots with it, blowing our stack, confusing our PC and wondering what it was we were supposed to be doing... Minotaur something something...
We’ve been looking at this the wrong way. Computers are not Ariadne's string. They are the labyrinth.
I'm going to tell you what the ball of string is, but you're not going to like it. It's paper, a whiteboard, an index card, something physical that is not in the labyrinth of your electronic devices, but in the real world, outside the labyrinth. You can’t expect the very thing that is the cause of your distraction to be its cure. If you get lost, you have your index card in front of you, or your whiteboard, and it will guide you when you get lost, and you will get lost, again and again, and you're human, so don't worry.
Don't pretend that one day you will wake up and be utterly goal-orientated, a mission machine, life isn't like that, humans aren't like that. Humans evolved to seek novelty. That's how we grow, except that this drive has been hijacked by psychologists working for tech companies and now we are all Amusing Ourselves To Death.3
You have to do this every day. Why? Because if you don't, I guarantee you will get lost and for some people, it might be days, weeks, decades until they find their way back, if they find their way back at all. I don't want to be on my death bed saying "Shit, I forgot about the Minotaur"
A stack is a computer data structure that stores a pile of similar objects. Think of it like a stack of plates of the same type or size. When you put a plate away, you put (PUSH) it on top of the stack (TOS). When you want to take a plate, you take (POP) it from the top of the stack.
Recursion is when a routine calls itself. Every time a routine calls another routine, (or calls itself) it puts the current program counter (PC) at TOS. When the called routine returns, it does so by grabbing the PC from TOS, which starts execution at the point the program was before this current subroutine was called.
“Amusing Ourselves To Death" by Neil Postman, a man who was decades ahead of his time.
Shahid, what is that keyboard in the pic - I'm bemused and intrigued!!
I really enjoy reading your posts. It's great the way you relate to your own experiences. More!
P.S. A couple of typos in footnote 2 ( whin & th)