Introducing the Raspberry Pi - Software Content from the guide to life, the universe and everything

Introducing the Raspberry Pi - Software

2 Conversations

Faculty of Science, Mathematics and Engineering

Introducing the Raspberry Pi
Software | Hardware | Peripherals You'll Need | Getting Started
The logo of the Raspberry Pi

This Entry will look at some of the operating systems and programs that the Raspberry Pi uses, and introduces the concept of programming languages.

Operating Systems

Every computer needs some form of operating system (OS) to direct its hardware, provide a user interface and allow software to be run. As it is open-source, making it free to use, Linux would seem the ideal OS for the job:

In the 1980s a type of operating system known as UNIX was too expensive for most people to use, and so the GNU Project was formed in 1986 to produce a free version. The project struggled until Linus Torvalds kindly wrote the central code required to make it all work. Thus, in 1994, the GNU/Linux operating system was born. Since then, many companies have taken this free code and created numerous 'distributions' of Linux, which are continuously being updated and improved.

The Raspberry Pi is fully compatible with several distributions of Linux, including Debian, Fedora and ArchLinux. Some of these will be available from the Raspberry Pi Foundation preloaded onto an SD card.

Linux Software

There is software for Linux to do more or less anything that a Windows PC might need to do. This includes text editors, presentation editors, web browsers, drawing programs, photo manipulators, calculators, printer drivers, and many penguin-related games. Better still, most of these are free under the same GNU General Public License (GPL) that covers Linux. As the Raspberry Pi has a memory card reader rather than a built-in Hard Disk Drive, you'll need to either buy a memory card with a Linux distribution pre-loaded, or buy a blank card and download an operating system onto it using another computer. Each distribution of Linux comes with its own collection of software, and as it is known that Debian, Fedora and ArchLinux are supported, we will look briefly at each.

Debian is a popular Linux distribution, including the GNOME GUI and a range of programs that fulfill most of the basic requirements of a home computer. This includes Iceweasel, a spin-off of the Firefox web browser1. It also includes an office program, typically, which can handle text documents, presentations, spreadsheets and the like. A similar package, koffice, is found in those distributions of Linux that run KDE in preference to GNOME, but can also be bundled with other distributions.

Fedora Linux is a Linux distribution popular with some power users. It is notable for continuous support of the ARM processor architecture that the Raspberry Pi uses. It has a short update cycle of 6 months, meaning that a given version of the operating system will initially be bleeding-edge but will be obsolete within just over a year. Fedora also uses GNOME, but comes bundled with LibreOffice and Firefox.

ArchLinux is a somewhat minimalist distribution of Linux aimed at speed, bug-free code and simplicity. It is possible to install only the absolute minimum required to run a computer, making it useful for users who have a specific task in mind. This distribution is therefore aimed at the more experienced Linux user, though it is still possible to install the X Desktop GUI and other software.

Linux Language

Some readers might recall MS-DOS, the text-only operating system that came before Microsoft started to use the Graphical User Interfaces (GUIs2) seen in Windows. MS-DOS was keyboard- and text-based, using typed commands to move files, run programs, print text and so forth – this was once the only way to interact with a computer. A similar text-only interface can still be found in Windows by opening the Command Prompt (the little black window with a blinking cursor).

Linux also comes with a text-based Command Line Interface (CLI), and any GUI you might run simply acts as an alternative to typing each command yourself. The difference between a Linux CLI and the old MS-DOS is that Linux is much, much better. After all, it was written largely by enthusiasts. You can open a CLI from your GUI's desktop, or switch to one and not have a GUI running at all. When you do so, a program known as a 'shell' starts running, and will convert any commands you type into something your computer will understand. This is usually the bash shell; however, there are plenty of CLIs that you might use to communicate with the bash shell, such as konsole, x-term or gnome-terminal.

Having brought up a CLI and thus connected to the bash shell, you'll be able to type all manner of commands. A few useful ones to start off with are:

help helpThis calls on the in-built help command to tell you about itself.
man man |moreIn a similar manner, displays the instruction manual entry about the manual command. The output is sent through |more so that the CLI pauses after each screen's-worth of text, rather than speeding straight to the end of the list.
pwdPrint Working Directory, which will tell you which folder you're currently in.
lsList Contents, which will list all the files and folders in the folder you're looking at.
ls -al |moreList Contents, modified by -al so that it lists all files (including hidden files) and lists full details.
cdChange Directory, which allows you to change directory. Entering cd .. takes you up one level.
./fredsprogramLooks for the executable file fredsprogram in the current folder and runs it.

One thing to note before doing anything drastic is the text and symbol that appears in your command line. If the line shows something like [email protected]: ~$ then you're logged in as a user. However, if it reads [email protected]: ~# then you're logged in as 'root'. An ordinary user can only do so much damage when using the command line, whereas someone logged in as root can delete the entire system with a single command. If you are logged in as root, don't do anything – learn how to log in as an ordinary user instead.

Programming Languages

The Raspberry Pi is aimed at encouraging a greater understanding of Computer Science, and would hardly be complete without supporting several programming languages. These are forms of code used to tell a computer what to do, and are what software and games industry coders spend a lot of time playing with. The Linux CLI mentioned above uses but one example of a programming language; others include C, C++, C#, Java, Python, BASIC, Perl, Haskell, Forth, COBOL, Fortran, MATLAB and many, many more. For an idea of what different programming languages look like, see 'Hello World!'

You'll probably be wondering, 'so which one of these does my computer speak?' The answer is none of them – your computer's processor understands a language called machine code. To us humans, a command in machine code can look something like this:


However, computer processors really talk in binary (zeroes and ones) and each of the letters and numbers above represents four zeroes or ones:

0    D    5    B    A    7    2    1
0000 1101 0101 1011 1010 0111 0010 0001

These ones and zeroes are the high and low voltages of electrical current passing between parts of your computer's processor. When you enter a command into a Command Line Interface (CLI), the bash shell turns your command into a bunch of zeroes and ones which are fed into the processor and tell it what to do.

Interpreted or Compiled?

In order to run a program you've written, you'll always need to convert it from Python, C or whatever else into machine code. Languages like Python are interpreted, which means each command you type is changed directly into machine code by an interpreter program. Interpreted languages are good because you can run them while you are still writing in order to test your program. The Linux bash shell is an interpreter, as it takes commands and turns them into machine code straight away.

Other programming languages need to be compiled, whereby a compiler program takes the finished program and forms a binary file which your processor can understand. The difference is that while an interpreter translates and runs what you've written line by line, a compiler takes the whole thing and fiddles around with it before producing a complete program. While this makes it harder to experiment, compiled languages are good because they are faster to run.

Both interpreters and compilers need sources of information telling them what particular commands do, how other things mentioned in your code should behave, and so on. These are known as libraries, and every interpreter and compiler program comes with a standard set. This standard set can be expanded in order to allow specialist uses of the programming language.

It's also worth mentioning here that different processor types have different structures, and use different flavours of machine code. This is why your operating system should support the Raspberry Pi's ARM processor, and any programming software must be suitable for your operating system.

High-level or low-level?

Programming languages differ in how easy they are to us. Low-level code is great for the computer but rather difficult for a person to understand, whereas high-level code uses human patterns of thinking and therefore translates a little clumsily into machine code. As a result, a high-level language such as Python will produce a slower program than the equivalent in a more low-level language like C++. However, as a beginner it is easier to learn Python.

Turing Completeness

One final attribute worth mentioning is whether a programming language is Turing-complete. In 1937, Alan Turing described a theoretical computer he called the Turing Machine. Given enough time, it could solve any mathematical problem it was given (save for those that were mathematically impossible to solve). Thus, a programming language that can tell a computer how to solve any mathematical problem is described as being Turing-complete. A programming language that isn't Turing-complete may not be able to do everything you want. Fortunately, most commonly-used languages are complete ones.

Choosing a Programming Language

For a beginner, a high-level language that can be run through an interpreter would be ideal – the language will be easy to understand, and can be tested by running it at any time. Good examples include Python, Perl, or perhaps versions of BASIC. Ruby is also worth a look as it is aimed at newcomers, tries not to be confusing, and has a few neat features – Ruby programs can be told to edit their own code whilst running. Languages such as C, C++ and C# are low-level, compiled and a little harder to learn, but each has its own advantages. If you're interested in coding for websites, then Javascript and PHP are worth looking at, and HTML (though not strictly a programming language) may also interest you. Whichever language you choose to learn, you should be able to find a wide range of software, manuals and books to aid you.

1Debian wanted to modify the free, open-source Firefox browser, but didn't have the rights to the Firefox name or logo, so re-branded the Debian version as Iceweasel.2A GUI allows the user to interact by pointing and clicking with a mouse, rather than by typing commands into their computer.

Bookmark on your Personal Space

Edited Entry


Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry

Categorised In:

Written by

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more