A program is a plan, a set of instructions, today usually meant for a computer :


Early computers had limited instructions they  could perform and limited resources.
Early computers did not even have buttons like your calculator.
Programs were assembled out of available operations.
If you wanted to add, you connected wires from the number register to the arithmetic unit using a plugboard.

As you can see, this was so clumsy that we soon replaced the wires and switches with words.
You assembled the words representing these available operations into an organized program.
So this was called assembly language programming.
Each computer had its own assemblly language code words.
And writing these programs  was called coding.

A simple program might be the same as you pressing buttons on your calculator like this:

         Assembly Language - Program for A + B = C


enter number 1    LOAD A         type first number
                                 type “+”
enter number 2    LOAD B         type second number
ADD               ADD            type “=”

STORE             STORE C        type memory store


Assembly language coding was so clumsy and slow that people wanted to write their programs 
   at a higher, more symbolic level.
So next we wrote programs which looked more like math or english.
And the computer would convert these programs into assembly language for you.
These programs were called compilers.
Here is a simple example in the popular programming language python;

# convert kilometers to miles

factor = 0.621371
kilometers = 5.5
miles = kilometers * factor
print(“kilometers = ", kilometers, ”, miles = “, miles)

kilometers = 5.500, miles = 3.418


We soon found that we want to collect useful programs. These beccame libraries.
There are now libraries for math, libraries for searching text, libraries for doing graphic drawings.
 These libraries contain tested procedures we find useful. We call those algorithms.

One of the most useful algorithms is for sorting.
Suppose I handed you a deck of cards with instructions: sort them.
How would you go about it? There are several different sorting methods. 

Bubble Sort: For example, you might look at your top card and see if the next card goes before or after it, rearranging as you go. After going throught the deck many times this way, finally all cards move into their right place. This is called a BUBBLE SORT, as the cards keep bubbling up unti all are in place. Unfortunately, this is a very slow method, proportional in speed to the square of the number of items sorted, so we only use it on small numbers of items.

There are better, faster ways to sort the cards.
You might break the deck up into smaller decks, sort them, then merge them.
Or you might take cards and instead of sorting them in place, move them into place in a new deck. 

Here is a fun link to Sorting Algorithm Animations with a simple display.  Watch them race.

NEXT >>>>> Thinking

© Gareth Harris 2019        -         Contact email:         -         see also: