Tuesday 20th December 2011

Introduction to Computers

All sorts of devices qualify as computers these days, not just the traditional personal computer, or the notebook computer, but also things like Apple's iPod Touch, iPhone and iPad.

Most people use computers without ever considering how the device works or if they are even using the device correctly. I'm hoping that this article gives you more of an understanding of how your computer works so you can become self sufficient when dealing with your machine.

Deep down inside

At its most fundamental level, a computer is simply a collection of transistor switches that turn on and off when electricity is sent through their control lines. Each switch is used to store the value of a binary digit or bit. When a switch is on it has a value of one and when it is off it has a value of zero. When bits are combined it is possible to represent bigger numbers using surprisingly few bits. Each bit in a sequence represents a number that is twice as big as the preceding number and half the size of the next. If we look at a sequence of eight bits (numbered 0 to 7) their values would be as follows...

# Value
0 1
1 2
2 4
3 8
4 16
5 32
6 64
7 128

Groups of bits are arranged eight at a time to represent a byte of data. Bytes themselves are arranged in larger groups to represent larger more complex pieces of data. We can use eight bits to represent numbers ranging from zero (00000000) to 255 (11111111) or any value in between e.g.

Value bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 1
10 0 0 0 0 1 0 1 0
25 0 0 0 1 1 0 0 1
33 0 0 1 0 0 0 0 1
128 1 0 0 0 0 0 0 0
254 1 1 1 1 1 1 1 0
255 1 1 1 1 1 1 1 1

Using more bits makes it possible to define bigger numbers, thus a 32 bit machine is capable of running calculations involving 32 bit numbers with values ranging from 0 to 4,294,967,295 in each number. Often one of the bits in a number is used to denote the numbers sign (positive or negative), this reduces the maximum value the number can hold but allows the number to have negative values as well. Thus a signed byte has a range from -127 to 127.

While this all seems far removed from the flat panel screen running the modern operating system you're probably reading this page on, suffice to say that there are such large numbers of these individually simple switches that the system as a whole is extremely complex and difficult to comprehend. The fundamental trick to understanding how the machine works in principal, is that data can be used in conjunction with logic gates to alter the circuitry of the machine from moment to moment. This allows a computer to be truly general purpose adapting to your needs as they change by simply changing the software (read bits) on the computer.

Programs

The complex sets of instruction data that the computer uses to reconfigure itself are called programs or software. Programs are streams of data compiled for particular computer design or architecture, when this data is processed by the computer, the program is said to be running on the machine. Everything your computer does requires explicit detailed instructions of which switches to switch on and which switches to switch off from moment to moment as the computer program runs. In the early days of computing, these switches were actual physical switches on the front of the machine. Early computer programmers were the people who toggled the switches.

Modern computer programs are typically written by programmers in a programming language. There are many programming languages each suited to meet the particular needs of the programmers that created them. All of them serve the same basic purpose: Programming languages attempt to abstract the programmer from the inherent complexity of the machine so that he or she can focus on solving the problems the program is designed to help with. Early programming techniques simply encoded individual switch positions for a type of computer to read them e.g. punch cards, later this was eventually replaced with the more abstract concepts like assembly language which allow the programmer to work with symbolic representations of particular machine operations which are then converted into machine code (raw data the machine can actually use) by a program called an assembler. Later still a third generation of programming technique came about in the form of high level languages that could be compiled from machine-independent source code into machine code for a target platform.

Without programs, your computer is simply a ball of ineffective wires waiting to be configured. When you switch on your computer a tiny and very simple program embedded directly into the hardware itself known as the BIOS is executed. This tiny program looks in a well known place for a more complex program, your computers operating system and attempts to load it. You can often see the BIOS start on your computer if you have a generic PC.

Operating System

The Operating System is yet more abstraction from the underlying complexity of the machine. An operating system is a program that provides an arena for other programs to operate within. An ideal operating system would contain all the commonly required programs to operate the machine as well as allow other programs to make easy use of the hardware devices in the machine as well. Modern operating systems include:

All of these operating systems have strengths and weaknesses and it's fair to say that none of them are perfect. Most people will be familiar with Windows and possibly OSX when it comes to the operating system they've seen running on PCs. There is a growing community of non-technical Linux users out there who've found out that not only is Linux free, fast and secure, but it's also pretty easy to use e.g. Ubuntu, Android.

Most software is written to run on or within the confines of one or more of these operating systems. Programs written for an operating system make use of that operating systems common programs (called libraries) so that each programmer does not have to re-invent the wheel whenever they write a new program. This explains why almost all file/open windows look the same and why the buttons, text boxes, labels and lists on your system all appear the same even in different programs, they all use common library functions that come with the operating system to draw these things on the screen. Their are as always exceptions to this rule, just because the libraries exist on the operating system does not mean that every programmer makes use of them!

Hardware & Peripherals

The hardware in a computer is all of the physical bits you can poke, by contrast the software is the invisible (and thus un-pokable) data that resides within the hardware.

Hardware is mostly used to process, transmit or store data (or some combination of the three). The heart of the computer is the central processing unit or CPU. The CPU can be thought of as the brain of the computer, it is the bit that processes data and performs the operations contained in programs.

Computer memory is connected to the CPU and provides a means to store data. This memory has two important metrics; speed and capacity. Often high capacity memory like a hard drive is orders of magnitude slower than the high speed RAM (random access memory) we also have in our computers. It's true to say as well however that high capacity memory is often much cheaper than high speed memory so there tends to be more cheap high capacity memory (hard drive) than fast low capacity memory (RAM) in a machine. Thus programs in use tend to be kept in RAM and programs that are not in use are kept on the hard disk. Launching a program often involves copying it from the hard disk into some fast access RAM where it can then be processed. Most modern operating systems make use of the RAM on your machine to seamlessly cache data that is otherwise stored on the hard disk, this makes repeat access to this data much faster than having to re-read it from the hard disk.

When data is not being stored or processed it is most often being communicated to other hardware devices for display, transmission or conversion into some other form for further processing, storage or transmission. Data sent to the graphics card in a computer is further translated by the graphics card into the shapes and text we see on the screen, data is also received from or sent to peripheral hardware which is connected to the host computer but not actually part of it. Good examples of peripheral devices are keyboards, printers, mice etc. All of these peripheral devices send and receive data to and from the host computer, all of this data is processed and interpreted by programs running in the CPU to perform the actions we've asked the machine to perform.