Where is the data?
Have you ever wondered where all of your email is stored? What about all those students and grades in the school software system?
Say you're writing a program and you want to store something. You'd create what's called a variable. As we saw in the video, variables are like storage boxes where you can put the data you want to store. When you, the programmer, create a variable, the computer reserves a space for it in computer memory. In this case, the computer will create an empty box in one of the lockers it's already dedicated for your program. When you finally decide to put something inside your variable box, the computer will find the right locker, locate the box, and put the item inside.
These variables all have precise types. I'm sure when you're putting leftovers away in food containers, or clothes and knickknacks in storage bins in your closet, you think about putting them in appropriately sized boxes. We also like to make sure we put things of the same type inside. You probably also don't mix socks with sweaters or leftover Indian food with your lasagna. Each type of clothing or food has its own special box.
With computers, it’s the same! The box should fit the contents within it. They all fit within your computer’s memory, like boxes on a shelf.
You also need to make sure to name them, so that you can find them again. Your computer’s memory is pretty vast, just like a warehouse full of boxes. This is why it makes sure to take down the location of each item as it stores it. It’s a little like using a barcode to track which boxes are where, as well as what they contain.
Just like in a warehouse system, having the name of what's in the box (basketballs, toy horses, shoes) helps humans remember what is where. We can't read barcodes, after all! It's the same with computers. Humans give variables a name in computer programming languages, but the computer needs the location.
Variables are a great place to start when learning about storing data, but there's so much more to know! Let's explore more about the data types we use with variables in the next chapter!
Variables are containers where we store data.
Variables are stored in specific locations in computer memory.
Variables have different types.
Variables have names.