# Comp 101 The Computer (Theoretically)

## Theoretical Model of Computing

Abstracting a computer into its components can be very useful as both a mental exercise and a way to understand how its systems work together. In this class, we'll be looking at three unique components of a computer:  memory, processor(s), and programs.

### Memory

Memory is a pretty abstract concept - and even more abstract to measure. However, storing information in 0’s and 1’s can be measured through terminology we likely already use. Everything from your computer’s RAM to your phone plan’s data cap use measurements in bytes.

A bit is the fundamental unit of a computer, and is a single digit of either 0 or 1. We can represent how many values are possible with bits by raising 2 to the power of how many bits we have.

```possible values = 2^(number of bits)
```

Kilo, Mega, Giga, and Tera are common ways we reference large bit amounts.

• 1 KB = 1,000 bytes
• 1 MB = 1,000 KB
• 1 GB = 1,000 MB
• 1 TB = 1,000 GB

Where we store data in a computer tells us a lot about the information that’s being stored.

• The CPU cache is the smallest of all the places we store data, but it’s really fast.
• RAM, or Random Access Memory, is volatile (everything erased when we restart -- why restarting can be so helpful for basic troubleshooting) and the second fastest.
• Secondary Storage, or our Hard Drive, is the slowest of all of our memory and where we store the things we aren’t currently using.

(Not so fun fact: Hard Drives are prone to fail sometimes. This will result in the loss of most if not all of your data. Remember to back up your data in the cloud or on an external hard drive!!!)

### Processor

The processor, or the CPU (Central Processing Unit), acts as the "brain" of your computer. It carries out the instructions and logic you outline when you write code by carrying out everything from simple arithmetic operations to complex memory retrieval and storage.

The CPU requires very explicit and simple instructions to do anything - even something as simple as multiplying some numbers!

### Program

Programming languages, like TypeScript, are translated by a specialized program into assembly -- a sort of in between language that is more human readable than binary/machine code but not quite as readable as TypeScript and other higher level languages -- and then finally into machine code (0’s and 1’s) for your computer to execute.

Programs are what allow us, as humans, to communicate with the computer (or, more specifically, its processor) and make it bend to our will! Thanks to computer scientists like Grace Hopper, we don't have to understand the world of 0's and 1's.

If we had to write assembly forever...