What are the basic commands used in computer programming languages?
Do you have any friends or family that program as a hobby or as a job? Have you ever looked over the shoulder of someone writing code and wondered, “How the heck do they make sense of all that gibberish?” One of the most frequent questions I’m asked is how do you learn programming.
I’m going to demystify programming by popping the hood and showing you that, without even knowing it, you may already know some of the basics.
Programs are simply a set of instructions that people give to computers to perform a task. Even if you hate computers, or think that you don’t know anything about programming, I’m sure you’ve used and written a handful of your own programs without even knowing it. If you’ve ever followed a recipe for cooking, put together something from Ikea, or explained to someone how to get to your house, you’ve written a program. In other words, you’ve followed a set of instructions someone else gave you, or you wrote instructions, for someone else.
Almost every programming language has the following statements in common: IF, THEN, ELSE, FOR, and WHILE. These commands are used to make decisions within a program and perform actions. Let’s look at IF and THEN. Say you’re out of milk and you want some cereal. In the form of a program that would look like “IF you need milk THEN you need to go to the store.” Writing programs use IFs and THENs to make decisions just how it sounds: if something happens then perform the following task.
Next let’s take a look at ELSE. ELSE would be like saying “otherwise.” For example IF you are out of milk THEN go to the store ELSE (otherwise) stay at home and watch Netflix. See it’s pretty easy to understand, right? Think of how many times you use that sort of logic in your head while driving, having conversations, going to the store, or making every decision. All can be formed into IF this happens, THEN do this, ELSE do that.
The next part of explaining coding has to do with loops. Loops are just fancy ways of waiting for something or performing an action a certain number of times. This is where FOR and WHILE come into play. Think of baking a cake: you have to put the cake in the oven FOR 20 minutes. You might use WHILE in a similar way (for example, WHILE the cake is baking keep the oven on).
These five basic words can be found in just about every programming language out there, and they all operate pretty similarly.
Storing Types of Data
Now that we know how programs make decisions, let’s take a look at what they do with that information, and where they get it from. Information in a computer program is stored in something called a “variable” which might be shortened down into just “var.” A variable is just something that stores information.
Think of your grocery list as a variable. It contains information about what you need from the store: avocados needed for your guacamole, , the name of your favorite chips, or what isle that can of soup is on. It simply contains information. Computers interpret data in a couple of ways, but on a basic level, they look at information as a “Number,” as just text known as a “String” (think of a string of letters), or a “List” (which can have numbers or text). Now different programming languages have a number of different ways they break these down even more, but for now that’s as deep as we’ll go.
If we were to write a quick program about you, we would need certain pieces of information. For example, if your name is Fred we might store that piece of information in the variable Name. If you’re 32, we might store that number in the variable Age. And if you have blue eyes, we might store that in the variable “Eye Color.” Variables can store any information, and can be named whatever you want. This makes it a lot easier to read and write programs.