Coding Memories: Decaying variables
It's the year 199X and I have received an annnnnncient 386 laptop from an uncle. When it boots up the 3.5-inch drive makes a grinding sound like "guuurrrrr geeeeeerrrrr" which is very inconvenient for starting it up late at night when I should be sleeping. The workaround, of course, is to start it up before I sleep, hide it under my bed, then bribe my sibling with whom I share a room to say nothing about my midnight tinkering.
The laptop only boots into DOS and has no way to connect to the internet. It was like a puzzle box for me. Quickly I learned to traverse to the directory filled with the commands that I can call and shortly thereafter I discovered QBASIC
. This was my first hook into programming. I was mystified by the openness of the text area. It could do... anything?
I scoured the library for every book I could find and came home with a treasure trove of reference material and program listings. By the time I was reading these books, they were old and largely forgotten. I'm sure that my checking them out kept them active in the library system for a little longer.
As I was pouring through a reference book I learned about variables and how they could get rewritten and at the end of the program they would disappear. I remember the ice and terror that filled my stomach. All of the work I had done to fill those variables with calculations, hopes, and dreams would just disappear at the end of the program. I can still conjure that terror.
I think about that because today I'm reviewing scoping rules in Javascript. var
for functional scoping and const
/let
for block scoping. The younger me would feel safer with var
because the variables hang around longer. All of the magic persists for just a few clock seconds more.