What Is Software?
This is an open source book, so you can download it free. It is based on the very popular How To Think Like A Computer Scientist: Learning With Python, which is also free, but to my mind at least it starts off much easier. Instead of jumping headlong into programming, it starts out discussing what a computer is and what programming is. A perfect introduction to programming.
~ o ~
For an open-source, world-class network protocol analyser.
Diceless role-playing in four-star luxury.
~ o ~
Computers do not do anything without software. Nothing at all. They don't sit there with an empty desktop. They don't complain about a missing boot disk. They might not even switch on. Everything a computer does is done by its software. Back in the late 1970's when the first personal computers came out, everyone who had one knew what software was. Software was what you wrote to get the computer to do something. Pretty soon companies like Microsoft sprang up to sell software to people who didn't want to write it themselves. These days writing your own software is highly unusual. Software is what you buy. It comes on DVDs that you put into a computer and "install". But what actually is it?
To Be Or Not To Be
It is said that computers only know about ones and zeros. In fact that is hopelessly anthropomorphic. Computers are machines that deal in on and off. Go into your hallway and take a look at the light-switch for the upstairs landing. What you have there is a computer. I don't mean there is a computer in there. Unless you are reading this a decade after I am writing it, or your name is Bill Gates, it's just two simple switches, a bit of wire and a light-bulb, but it's still a computer. This computer can only answer one question: "Are both switches in the same state?" If both switches are down, or both switches are up, then the light turns on, otherwise it is off.
In the first half of the twentieth century, people realised that they could connect together large numbers of these sorts of circuits and get them to answer more complex questions. First they used relays. Relays are just switches that can be switched on and off with an electric current. So the light-bulb on your landing gets replaced with a relay. Then if both switches are up or down the relay turns on. The switch in the relay is then part of the next circuit, which turns on another relay, and so on.
Relays, being mechanical devices, don't have very high reliability, and they take a significant fraction of a second to operate, so people stopped using them and used valves instead. Valves are just like relays, but faster and more reliable. Later they used transistors, but only to get higher speeds and reliability; the transistors do exactly the same as relays did.
That Is The Question
It is all very well building a computer that can answer yes and no questions, but it does not get you very far. That is where ones and zeros come in. If we decide that a light being on means one, and a light being off means zero then a computer can count, albeit only as high as one, which is not much use. But there is another trick you can pull. If you put two light-bulbs together then you can say that the first means one or zero, and the second means two or zero. This computer can count to three:
|off||off||0 + 0||0|
|off||on||0 + 1||1|
|on||off||2 + 0||2|
|on||on||2 + 1||3|
By adding more circuits a computer can count as high as you need it to.
Which is all well and good; with a computer like this you can calculate useful stuff like bomb-aiming tables and logarithms, but if you want it to do something else then you need to rebuild it. That is not very practical, but it was computers like this that broke codes in the second world war. Shortly after that people realised that these computers could do something amazing. They could pretend to be a computer — any computer. The computer could still only do one job but, by changing the parameters of that job, they could pretend to be a computer that did some other job. Changing those parameters was a lot faster and cheaper than rebuilding the computer all the time. Those parameters that need to be designed to build the pretend computer, are the software.
As you might imagine, designing those parameters — writing that software — is a highly complex task. If you build the computer carefully you can make it a bit more logical, but there is a limit. Writing those parameters is always going to be difficult and tedious, but difficult and tedious tasks are what computers are good for. And so it was time for another neat trick: get the computer to translate from a language people could understand into a language the machine could understand.
|Source Code||Software written in a language that people can understand.|
|Object Code||Software written in a language that a machine can understand.|
|Program||A piece of software|
|Compiler||A program for translating source code into object code|
Now people could write software with sentences like "SUBTRACT COSTS FROM TURNOVER GIVING PROFIT" and "AREA =PI * R**2" and let the computer translate that into a language it could understand. People can write a large number of such sentences without making mistakes, and so software can do more if it is written in source code. Over time computers have become faster and more complex and software has got larger and more complex to match. It is still just a large collection of settings for a large number of switches, each of which can be on or off.
People who sell software often don't want to give their secrets away, so they only put the object code on the DVDs. They keep the source code to themselves. That means that while the computer can understand the software, to the computer's owner it's all just mysterious gobbledygook. Software has become a strange thing that makes their computer do something
Suppose the programmer, instead of writing "SUBTRACT COSTS FROM TURNOVER GIVING PROFIT", had written "ADD COSTS TO TURNOVER GIVING PROFIT". The program would do something but it would not be correct. The pretend computer that the software made would be doing the wrong job. Programmers are people and people make mistakes, so all software starts out with bugs in it. Hopefully before it is delivered, most of these bugs have been found and removed. But with the huge complexity of modern software it is rarely practical to remove them all, or even detect them all. The software implements a pretend computer that does almost what you want, and that is usually good enough.
So Where Is The Software?
When you turn on your PC, the first software that is activated is in a chip on the circuit-board. This is the BIOS, which stands for "Basic Input/Output System". The BIOS is written specially for one type of circuit board, so it can test it and configure its various features. It can also access hard-disks, DVDs and so forth, and load a particular small program from them. This small program is called the Boot-Loader. It is written for a particular type of device — hard-disk, DVD, USB memory stick, etc. — and a particular operating system, and so it can load the operating system from the storage device. The Operating System, which might be Windows, MacOS or Linux for example, then loads the various programs that make the PC what you recognise; starting up the video card, displaying the desktop and toolbars, driving the various devices. Then the user comes along, moves the pointer to a game icon and double-clicks. The operating system moves the pointer on the screen, detects a double click, works out which icon is under the pointer, loads the associated program from the hard-disk, and the game starts to execute.