The Computer Basics
The RAM, The HD and The CPU – The Three Musketeers
There aren’t too many differences between a hard drive and RAM (Random Access Memory)—but they’re both very important for the computer.
CPU aka. The Processor (Central Processing Unit)
The CPU is the brains of the computer. Without the CPU, you wouldn’t be able to do very much on your computer!!
The CPU really only does very simple instructions. This might be adding 2 + 2, multiplying 5 * 8, or moving a number into the computer’s memory for later use.
When you “compile” your program, what the computer is actually doing is converting your human readable program into little codes called opcodes that the CPU understands.
Here’s an example of what compiling a simple program to CPU opcodes might look like:
// Create integer with the value 0 int my_fav_number = 0; // Change the variable's value to 13 my_fav_number = 13;
00101100 00000000 // 00101100 (code to create a variable) 00000000 (0 in binary) 00011101 00001101 // 00011101 (code to change variable) 00001101 (13 in binary)
Think of the CPU as a tiny little chip that does extremely basic instructions(about 3 billion instructions a second—very fast) that takes ones and zeros as input and then does something based on what those numbers were; which might be multiplication, addition, subtraction, multiplication, or maybe something a little more complicated, like moving a value into the computer’s memory. And depending on what the CPU just did a nanosecond ago, it might make your computer do something—like move your cursor across your screen.
Note: This is a pretty tricky concept, but don’t overthink it! It’s actually pretty simple!
RAM aka. The Memory (Random Access Memory)
Think of a computer’s RAM as just a huge Google Spreadsheet, except with about 8,589,934,592 (8 Gigabytes) cells. Each of those cells in our Spreadsheet represent one byte, which can hold only numbers ranging from 0 – 255. But get this, many years ago people realized that we can combine multiple cells in our spreadsheet to get ebigger numbers!
Anyway, each cell in our Spreadsheet has a special ID, we’ll call this the Memory Address(Remember that!). In Google Spreadsheets, the first cell’s memory address is A1, and the second would be B1. But a real computer wouldn’t use codes that human readable to locate items in the computer’s memory… Instead it uses Hex Codes—which is much easier way to read binary numbers.
Hex Codes look like this:
00 – Start of memory (0th cell in memory)
0A – 10th cell in memory
14 – 20th cell in memory
FF – End of memory (255th cell in memory)
What makes the computer’s RAM so different from the computer’s Hard Drive is that when a computer shuts down, the RAM is wiped. This is because RAM need to be powered all the time! In other words, once the computer loses power, all the Zeros or Ones will reset to ZERO. This is why when your computer restarts, all the applications are closed (because they’ve been reset)!
Also RAM is about 16x faster to read and write to compared to an average Hard Drive. Which is why most applications use the computer’s memory instead of hard drive for storing temporary data. For example, say I’m making a game, and I need to store the player’s X and Y position. If I stored it in the computer’s Hard Drive, my player might lag because it takes a while (in computer time) to read and write that data to the Hard Drive. Instead if I store the players position into memory, my player would probably move swiftly across the screen.
HD (The Hard Drive)
I’m sure you know how this one works. It’s basically just like RAM, except it writes data (1s and 0s) to a Hard Drive somewhere in your computer. So, when your computer shuts down, your data isn’t lost (very handy)!