Tuesday 30 August 2011

Problems and stories

Lately I've been thinking about how everything programming is really just loads of problems. I don't mean emotional ones (though solving them has know to create a few...) but more how to do something ones.

The more I have to understand new programming concepts (new to me anyway) the more I find thinking about a problem that could have caused someone to invent this concept helps.

An illustration

For example, take the idea of a PATH system variable. So at some point a programmer is working on a Python program and some shell scripts. She keeps needing to run programs inside of these that aren't part of the Python language or variables set up by the shell. She also has to keep executing them by typing the whole path to them.

So the problem is:

  • How to use common references to programs across an Operating System.
  • How to abbreviate the running of a program from having to type a whole path to the executable.

So, assuming environment variables have already been invented, the first bit is solved already.

The second bit is solved using a bit more thought.

Using the knowledge that you can run a program by typing its name if you're in the same folder, she takes the first bit and makes the second bit if you're in any of the following folders.... Those folders are just a list of paths in a string.

Storing the list of paths as an environment variable she makes it possible for all programs to have access to this.

I know this has nothing to do with how or why PATH was created but it doesn't matter. People learn through narrative and experience so creating a story around it and going through similar motions of problem solving can really help create a feeling of both.