1.1.2 What is software?
Talk is cheap. Show me the code. — Linus Torvalds
Software is code that tells computer hardware what to do.
To get started, let’s write a very simple software program.
For this, the first thing you need to do is start a terminal with a Unix shell in it.
I can’t tell you how to do this exactly as this is operating system (OS) dependent. At least with some versions of Mac OS, you can start the terminal by searching for “terminal” in Spotlight. On Windows 10, you can install “Windows Subsystem for Linux” (WSL). On older Windows versions, there are ways to get a Unix shell like Cygwin but it’s more tricky. Searching on- line is your friend.
In the end, it could look something like this:
Most notably, the Windows cmd.exe or PowerShell are not Unix shells. Typical Unix shells characteristics are the at sign (“@”) designating your user name and the host name of the computer you’re logged on to, a tilde (“~”) to designate the home directory and the dollar sign (“$”) to designate the prompt. You can use these to identify whether you’re running a Unix shell or not.
Exercise: Start a terminal with a Unix shell.
Is this “Unix shell” the only way to program?
No, it’s also possible to program in other environments than Unix shell. However, Unix shell is one environment, and it’s a pretty good one (author’s opinion). If you’re familiar with the Unix shell, it shouldn’t be very difficult to learn to use another environment should that become necessary.
Apart from the shell, we also need an interpreter and an editor. For this section we’ll use Python as our programming language; so let’s install the Python interpreter. Again, I can’t tell you how to do this; some OSes may have it already installed. To find out if you have it, start your Unix shell and try typing:
I’m supposed to type all that?
Actually you’re only supposed to type “python” (without quotes). On the first line, the dollar sign (“$”) means the prompt, i.e. the part of the screen where you can type. The first line effectively means “type ‘python’”. The following lines don’t start with the dollar sign so they’re meant to demonstrate the possible output from running the previous command.
If you don’t have Python, you might see something like this instead:
In this case you’ll need to find out how to install it. On e.g. Ubuntu, running something like “sudo apt-get install python” might do it. On Mac you may need to install Python from the Python official web site. Although we’ll be using Python 2 later in this book, this section will work with either Python 2 or 3 so the version you pick isn’t very important for now.
Once you do get to the Python interpreter as shown above you can exit it by typing “exit()” (without the quotes).
Exercise: Install the Python interpreter if your system doesn’t already have it. Run it and exit it.
Now that we have the shell and the interpreter, the final bit we need is the editor. An editor is a program that allows writing code files, or text files in general. For now it’s enough with an editor that’s easy to use, though Notepad, which is installed by default on Windows, won’t do. Furthermore, word processors such as Microsoft Word won’t do. If you’re on a Linux system you can install e.g. gedit. On Windows you could install notepad++. There are other editors available like Atom or Visual Studio Code. It doesn’t really matter which one you install now, as long as you end up with a window where you can type text and save it to a file. Here’s an example of what an editor could look like: