Computer Hardware for programmers

Posted 2013-09-10 02:11 AM GMT

Some programmers know a lot about hardware. I am not one of those programmers. I do know a little, though its probably not even enough to be dangerous. Below I will discuss what I consider the three most important pieces of computer hardware for a software developer to understand. Please correct me where I'm wrong.

CPU

The Central Processing Unit (CPU) is the workhorse of the computer. The other pieces of hardware we will discuss are used to support the CPU in some way or another.

Now is probably the best time to bring up a rather awkward subject. Computers are pretty stupid. They are also very obedient. They will do whatever we tell them to do, with two conditions:

  • They are capable of executing the instructions. For instance, just because you tell a computer to make you a sandwich doesn't mean you're going to get a sandwich (try using sudo and you may have more luck). Most computers just can't make sandwiches.
  • They can understand your instructions. This is where programming languages are useful.

A computer's willingness to execute any and all instructions it receives is the reason we have bad software (both low quality and malicious). A computer will never receive an instruction and think "I'm not doing that!" Computers don't think; they just do. This is also the reason we have really good software. There are no limits to what can be created. It is truly amazing.

The CPU is the part of the computer that actually executes the instructions. It is a small, seemingly insignificant chip that has created a multi-billion dollar industry. It has been featured on Formula One cars and Pro Cycling Jerseys. It has been the subject of several Super Bowl commercials. It's a big deal.

RAM

While the CPU executes the instructions, RAM (Random Access Memory) is the place where instructions wait to be executed. Think of it as short term memory. If I were to tell you how to build a paper airplane, my instructions couldn't be stored in your hands, even though your hands are actually executing my instructions. Instead, the instructions are kept in your short term memory, and executed by your hands one at a time. RAM also stores any data, such as variables, that is relevant to the program's execution.

If you're like me, you can hold about 4 instructions in your head at once, and you probably ask for these instructions to be repeated several times. Fortunately, a computer's short term memory is much better than yours. Computers have unparalleled concentration, they don't forget until you tell them to forget, and they can hold millions of instructions at once in short term memory (which is one of the reasons more RAM means your computer tends to perform better. It doesn't have to keep going back and asking for more instructions). However, RAM does have a limited capacity, and everything stored in RAM is wiped out when your computer turns off.

The CPU and RAM work very closely and quickly. They are positioned very close to each other inside the computer, so communication is fast. They have no moving parts, so performance is fast. They are a great team, but where do all the instructions come from?

Hard drive

The computer actually isn't too picky about where instructions come from. So instructions can come from a number of places, like the command line, a file that is downloaded directly into RAM (like a JavaScript file on a web page), or from a file in the computer's hard drive.

A computer's hard drive is long term memory. Hard drives are the place to put things that you don't want the computer forget, ever. Even if the computer gets turned off. We will think of a hard drive as a collection of files. There are all kinds of files on a hard drive. Your hard drive probably has images, presentations, and rich text documents. Your hard drive also stores files containing instructions. When these instructions are executed by the computer, an arm swings out and finds the instructions on the hard drive, reads them, and sends them to RAM, and they are fed into the CPU for execution.

A traditional hard drive is an array of platters and swinging arms, encased in an aluminum box. The whole system is very precise and delicate. At the end of the arm is a head, which can read and write to the platters. The head "flies" within 3 nanometers of the platter. The swinging arm and the spinning disk make traditional hard drives very slow relative to RAM (newer Solid State Drives, with no moving parts, are much faster). When the computer is shut down, the arms swing clear of the platters, so there is not danger of collision. If there is a collision, however, the hard drive can be corrupted. Now you know why it's not a good idea to jog with a laptop that is on :)