home comics writing pictures archive about

2016-12-17 - Programs aren't Permanent

After a certain age people begin to understand that objects still exist when you put them away. If you put a hammer on a shelf today it will likely still be there in a week and still be the same hammer. Programs on the other hand don't keep when you stop using them, at least not in the same way.

This is because programs don't contain components the way we would normally think of them. A hammer is made up of pieces of metal and plastic. The hammer is a hammer because of the specific shape of those pieces and how they are put together. A program isn't made up of stuff, it is made up of instructions.

When a program is launched it starts executing the instructions stored within it. These instructions generally start by building up data structures in memory that store a program's state. When a program is closed those data structures are destroyed. The information stored within them may be persisted into another form but the exact data structures the program was using to run no longer exist.

Imagine having to rebuild the hammer every time you needed to use it. The hammer would change each time based on the current circumstances. Maybe there wasn't a lot of free plastic one time so you ended up with a very short hammer, or there was an issue getting the metal so you ended up with just a handle.

Because a program is just instructions it is very dependant on the results of those instructions. If the results can change from one run to another then the program's behaviour can change. Some times it launches fine and other time it crashes immediately. It's all up to the circumstances in which the program is being launched.

This is why restarting a program can make it run better.

Comments: